Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (2)
Showing
with 190 additions and 144 deletions
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Nightmare
{
public class CancelFullHpPet : CheatCommandBase
{
public override string commandID { get; protected set; }
public override string commandDescription { get; protected set; }
public CancelFullHpPet()
{
commandID = "cancel_full_hp_pet";
commandDescription = "Your pet can die, you evil pet owner";
AddCommandToConsole();
}
public override void RunCommand()
{
CurrentStateData.SetPetGodMode(false);
}
public static CancelFullHpPet CreateCommand()
{
return new CancelFullHpPet();
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 9ec5883010fa24542bbf2240866abc90
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Nightmare
{
public class CancelNoDamage : CheatCommandBase
{
public override string commandID { get; protected set; }
public override string commandDescription { get; protected set; }
public CancelNoDamage()
{
commandID = "cancel_no_damage";
commandDescription = "Back to reality, you can die";
AddCommandToConsole();
}
public override void RunCommand()
{
CurrentStateData.SetPlayerGodMode(false);
}
public static CancelNoDamage CreateCommand()
{
return new CancelNoDamage();
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: d28db1fd56225524a886be2aa7230022
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -22,9 +22,16 @@ namespace Nightmare
public override void RunCommand()
{
_playerMovement = _player.GetComponent<PlayerMovement>();
// Double the speed but ensure it does not exceed 12
/*float doubledSpeed = _playerMovement.speed * 2;
_playerMovement.speed = Mathf.Min(doubledSpeed, 12f);*/
if (_playerMovement.GetCurrentSpeed() <= 0f)
{
_playerMovement.SetCurrentSpeed(2f);
}
else
{
// Double the speed but ensure it does not exceed 12
float doubledSpeed = _playerMovement.GetCurrentSpeed() * 2;
_playerMovement.SetCurrentSpeed(Mathf.Min(doubledSpeed, 12f));
}
}
public static DoubleSpeed CreateCommand()
......
......@@ -9,13 +9,6 @@ namespace Nightmare
public override string commandID { get; protected set; }
public override string commandDescription { get; protected set; }
/* private GameObject healerPet;
private GameObject attackerPet;
private GameObject buffPet;
private PetWizardHealth petWizardHealth;
private PetDragonHealth petDragonHealth;
private int currentPet;*/
public FullHpPet()
{
commandID = "full_hp_pet";
......@@ -26,34 +19,7 @@ namespace Nightmare
public override void RunCommand()
{
/* currentPet = CurrentStateData.GetCurrentPet();
if (currentPet != -1)
{
ImmortalPet(currentPet);
//CurrentStateData.RemoveCurrentPet();
}*/
}
private void ImmortalPet(int currentPet)
{
/* if (currentPet == 0)
{
healerPet = GameObject.FindGameObjectWithTag("Healing Wizard");
petWizardHealth = healerPet.GetComponentInChildren<PetWizardHealth>();
petWizardHealth.Immortal();
}
else if (currentPet == 1)
{
attackerPet = GameObject.FindGameObjectWithTag("Pet Dragon");
petDragonHealth = attackerPet.GetComponentInChildren<PetDragonHealth>();
petDragonHealth.Immortal();
}
else if (currentPet == 2)
{
buffPet = GameObject.FindGameObjectWithTag("Aura Buff Wizard");
petWizardHealth = buffPet.GetComponentInChildren<PetWizardHealth>();
petWizardHealth.Immortal();
}*/
CurrentStateData.SetPetGodMode(true);
}
public static FullHpPet CreateCommand()
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Nightmare
{
public class HalfSpeed : CheatCommandBase
{
public override string commandID { get; protected set; }
public override string commandDescription { get; protected set; }
private GameObject _player = GameObject.FindGameObjectWithTag("Player");
private PlayerMovement _playerMovement;
public HalfSpeed()
{
commandID = "half_speed";
commandDescription = "Your speed decreased 1/2, you will move like Gary the snail";
AddCommandToConsole();
}
public override void RunCommand()
{
_playerMovement = _player.GetComponent<PlayerMovement>();
_playerMovement.SetCurrentSpeed(_playerMovement.GetCurrentSpeed() / 2);
}
public static HalfSpeed CreateCommand()
{
return new HalfSpeed();
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 6547405238f6ed148b3c4d7cdea9a46d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -9,53 +9,17 @@ namespace Nightmare
public override string commandID { get; protected set; }
public override string commandDescription { get; protected set; }
/*private GameObject healerPet;
private GameObject attackerPet;
private GameObject buffPet;
private PetWizardHealth petWizardHealth;
private PetDragonHealth petDragonHealth;
private int currentPet;*/
//private ShopKeeperCanvasManager manager;
public KillPet()
{
commandID = "kill_pet";
commandDescription = "Instantly killing current pet";
commandDescription = "Your cutie pets die... you heartless!";
AddCommandToConsole();
}
public override void RunCommand()
{
/*currentPet = CurrentStateData.GetCurrentPet();
if (currentPet != -1)
{
Kill(currentPet);
CurrentStateData.RemoveCurrentPet();
//currentPet = CurrentStateData.GetCurrentPet();
}*/
}
private void Kill(int currentPet)
{
/*if (currentPet == 0)
{
healerPet = GameObject.FindGameObjectWithTag("Healing Wizard");
petWizardHealth = healerPet.GetComponentInChildren<PetWizardHealth>();
petWizardHealth.TakeDamage(petWizardHealth.currentHealth);
}
else if (currentPet == 1)
{
attackerPet = GameObject.FindGameObjectWithTag("Pet Dragon");
petDragonHealth = attackerPet.GetComponentInChildren<PetDragonHealth>();
petDragonHealth.TakeDamage(petDragonHealth.currentHealth);
}
else if (currentPet == 2)
{
buffPet = GameObject.FindGameObjectWithTag("Aura Buff Wizard");
petWizardHealth = buffPet.GetComponentInChildren<PetWizardHealth>();
petWizardHealth.TakeDamage(petWizardHealth.currentHealth);
}*/
PetManager.killPet = true;
}
public static KillPet CreateCommand()
......
......@@ -8,8 +8,6 @@ namespace Nightmare
{
public override string commandID { get; protected set; }
public override string commandDescription { get; protected set; }
private GameObject player = GameObject.FindGameObjectWithTag("Player");
private PlayerHealth playerHealth;
public NoDamage()
{
......@@ -21,8 +19,7 @@ namespace Nightmare
public override void RunCommand()
{
playerHealth = player.GetComponent<PlayerHealth>();
playerHealth.godMode = true;
CurrentStateData.SetPlayerGodMode(true);
}
public static NoDamage CreateCommand()
......
......@@ -13,15 +13,16 @@ public class CurrentStateData
_currentStateData.scoreEntries ??= new List<ScoreEntry>();
_currentGameData.playerName = _currentStateData.playerName;
_currentGameData.playerGodMode = false;
_currentGameData.difficulty = _currentStateData.difficulty;
_currentGameData.scene = "Level01";
_currentGameData.star = 0;
_currentGameData.playTime = 0;
_currentGameData.currentWeapon = 0;
_currentGameData.pets = new List<int>();
_currentGameData.petGodMode = false;
_currentGameData.weapons = new []{true, true, true};
_currentGameData.dmgMultiplier = 1f;
_currentGameData.currentPetHealth = -1;
}
public static void SaveStateData()
......@@ -69,13 +70,14 @@ public class CurrentStateData
var loadedSaveEntry = _currentStateData.saveEntries[index];
_currentGameData.playerName = loadedSaveEntry.playerName;
_currentGameData.playerGodMode = loadedSaveEntry.playerGodMode;
_currentGameData.scene = loadedSaveEntry.scene;
_currentGameData.star = loadedSaveEntry.star;
_currentGameData.playTime = loadedSaveEntry.playTime;
_currentGameData.currentWeapon = loadedSaveEntry.currentWeapon;
_currentGameData.weapons = loadedSaveEntry.weapons;
_currentGameData.currentPetHealth = loadedSaveEntry.currentPetHealth;
_currentGameData.pets = loadedSaveEntry.pets;
_currentGameData.petGodMode = loadedSaveEntry.petGodMode;
return true;
}
......@@ -87,13 +89,14 @@ public class CurrentStateData
saveName = saveName,
saveDateTime = DateTime.UtcNow.AddHours(7),
playerName = _currentGameData.playerName,
playerGodMode = _currentGameData.playerGodMode,
playTime = _currentGameData.playTime,
star = _currentGameData.star,
scene = _currentGameData.scene,
currentWeapon = _currentGameData.currentWeapon,
weapons = _currentGameData.weapons,
currentPetHealth = _currentGameData.currentPetHealth,
pets = _currentGameData.pets
pets = _currentGameData.pets,
petGodMode = _currentGameData.petGodMode,
};
_currentStateData.saveEntries[index] = saveEntry;
......@@ -122,6 +125,16 @@ public class CurrentStateData
return _currentGameData.playerName;
}
public static void SetPlayerGodMode(bool godMode)
{
_currentGameData.playerGodMode = godMode;
}
public static bool GetPlayerGodMode()
{
return (_currentGameData.playerGodMode);
}
public static int GetCurrentStar()
{
return _currentGameData.star;
......@@ -146,30 +159,6 @@ public class CurrentStateData
return true;
}
public static int GetCurrentCoin()
{
return _currentGameData.coin;
}
public static void SetCurrentCoin(int coin)
{
_currentGameData.coin = coin;
}
public static void AddCoin(int coin)
{
_currentGameData.coin += coin;
}
public static bool SubtractCoin(int coin)
{
if (_currentGameData.coin < coin)
return false;
_currentGameData.coin -= coin;
return true;
}
public static float GetCurrentPlayTime()
{
return _currentGameData.playTime;
......@@ -190,33 +179,14 @@ public class CurrentStateData
_currentGameData.scene = scene;
}
public static int GetCurrentPet()
{
if (_currentGameData.pets.Count > 0)
{
return _currentGameData.pets[0];
}
else
{
return -1;
}
}
public static List<int> GetAllPets()
{
return _currentGameData.pets;
}
public static void RemoveCurrentPet()
public static void RemoveAllPets()
{
if (_currentGameData.pets.Count > 0)
{
_currentGameData.pets.RemoveAt(0);
}
else
{
throw new Exception("No Pet Found");
}
_currentGameData.pets.Clear();
}
public static void AddPet(int pet)
......@@ -229,16 +199,6 @@ public class CurrentStateData
return _currentGameData.pets.Count;
}
public static int GetCurrentPethealth()
{
return _currentGameData.currentPetHealth;
}
public static void SetCurrentPethealth(int amount)
{
_currentGameData.currentPetHealth = amount;
}
public static bool[] GetWeapons()
{
return _currentGameData.weapons;
......@@ -269,4 +229,14 @@ public class CurrentStateData
{
_currentGameData.dmgMultiplier = multiplier;
}
public static void SetPetGodMode(bool godMode)
{
_currentGameData.petGodMode = godMode;
}
public static bool GetPetGodMode()
{
return (_currentGameData.petGodMode);
}
}
\ No newline at end of file
......@@ -43,10 +43,13 @@ namespace Nightmare
private void CreateCommands()
{
NoDamage.CreateCommand();
CancelNoDamage.CreateCommand();
OneHitKill.CreateCommand();
Motherlode.CreateCommand();
DoubleSpeed.CreateCommand();
HalfSpeed.CreateCommand();
FullHpPet.CreateCommand();
CancelFullHpPet.CreateCommand();
KillPet.CreateCommand();
/*OrbDamage.CreateCommand();
OrbHealth.CreateCommand();
......
......@@ -10,6 +10,7 @@ namespace Nightmare
public GameObject attackerPet;
public static bool tryToSpawnNewPet = false;
public static Transform nextTransform;
public static bool killPet = false;
private GameObject player;
private List<GameObject> instantiatedPets = new List<GameObject>(); // List to store instantiated pets
......@@ -25,6 +26,11 @@ namespace Nightmare
void Update()
{
if (killPet)
{
RemoveAllPets();
killPet = false;
}
if (tryToSpawnNewPet)
{
RemoveAllPets();
......
......@@ -14,6 +14,7 @@ namespace Nightmare
CapsuleCollider capsuleCollider;
PetMovement petMovement;
PetManager petManager; // Reference to PetManager
public bool godMode = false;
void Awake()
{
......@@ -53,6 +54,11 @@ namespace Nightmare
public void TakeDamage(int amount)
{
if (CurrentStateData.GetPetGodMode())
{
return;
}
if (!IsDead())
{
petAudio.Play();
......
......@@ -72,7 +72,7 @@ namespace Nightmare
public void TakeDamage(int amount)
{
if (godMode)
if (CurrentStateData.GetPlayerGodMode())
return;
// Set the damaged flag so the screen will flash.
......
......@@ -3,14 +3,14 @@
public struct GameData
{
public string playerName;
public bool playerGodMode;
public string difficulty;
public int coin;
public int star;
public float playTime;
public string scene;
public List<int> pets;
public bool petGodMode;
public int currentWeapon;
public bool[] weapons;
public float dmgMultiplier;
public int currentPetHealth;
}
\ No newline at end of file
......@@ -7,11 +7,12 @@ public struct SaveEntry
public string saveName;
public SerializableDateTime saveDateTime;
public string playerName;
public bool playerGodMode;
public int star;
public float playTime;
public string scene;
public int currentPetHealth;
public List<int> pets;
public bool petGodMode;
public int currentWeapon;
public bool[] weapons;
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ public class StateData
{
public string playerName = "Player";
public string difficulty = "Medium";
public int volume = 100;
public int volume = 50;
public SaveEntry[] saveEntries;
public List<ScoreEntry> scoreEntries;
......