Exemple #1
0
    void calculateFirstTurnPvP()
    {
        // calculate who goes first
        CardData activeCard   = _GameStateHolder._ActivePlayer.GetCardOfType(CardType.Priority_Card),
                 inactiveCard = _GameStateHolder._InactivePlayer.GetCardOfType(CardType.Priority_Card);

        if (activeCard != null ^ inactiveCard != null)
        {
            // one player has a priority card, which one?
            if (inactiveCard != null)
            {
                activePlayer = BattlerType.Opposition;
                _GameStateHolder._InactivePlayer.RemoveCard(inactiveCard);
                Debug.Log(_GameStateHolder._InactivePlayer.GetType() + " used priority card to go first");
            }
            else
            {
                activePlayer = BattlerType.Instigator;
                _GameStateHolder._ActivePlayer.RemoveCard(activeCard);
                Debug.Log(_GameStateHolder._ActivePlayer.GetType() + " used priority card to go first");
            }
        }
        else
        {
            calculateFirstTurnNonPvP();
        }
    }
Exemple #2
0
    public int Attack(BattlerType t, iBattleable target)
    {
        int totalDamage = 0;

        if (t == BattlerType.Instigator)
        {
            totalDamage = _instigatorBattlers.Sum(x => x.GetStrength());
            Audio.AudioInstance.PlaySFX(_instigatorBattlers[0].GetAttackSound());
        }
        else
        {
            totalDamage = _oppositionBattler.GetStrength();
            Audio.AudioInstance.PlaySFX(_oppositionBattler.GetAttackSound());
        }
        target.ReduceHP(totalDamage);
        OnBattleAbleTakeDamage(target, totalDamage);
        OnBattleAbleUpdate(target);

        if (target.IsKO())
        {
            Audio.AudioInstance.PlaySFX(target.GetDeathSound());
        }
        else
        {
            Audio.AudioInstance.PlaySFX(target.GetHitSound());
        }

        Debug.Log(t + " attacked " + target.GetType() + " for " + totalDamage + " damage.");
        Debug.Log(target.GetCurrentHP() + " hp left (" + target.GetHPPercentage() * 100 + "%)");
        return(totalDamage);
    }
Exemple #3
0
 void DeathStatus(BattleBehavior behavior, BattlerType type)
 {
     if (behavior.Name == Character.BattleBehavior.Name)
     {
         statusText.text = "Fainted";
         statusText.color = Color.white * 0.85f;
     }
 }
Exemple #4
0
 public void HideChest(BattlerType t)
 {
     if (t == BattlerType.Instigator)
     {
         _TreasureChestInstigator.SetActive(false);
     }
     else
     {
         _TreasureChestOpposition.gameObject.SetActive(false);
     }
 }
Exemple #5
0
    // Use this for initialization
    void Start()
    {
        Fader.ScreenFader.StartFadeOverTime(Fader.FadeDir.FadeOut, SceneSnapshot.ScreenSnapshot.SnapScreenShot);
        // set up the players
        _StormshaperPlayer = _GameStateHolder._ActivePlayer.Type == PlayerType.Stormshaper ? _GameStateHolder._ActivePlayer : _GameStateHolder._InactivePlayer;
        _BattlebeardPlayer = _GameStateHolder._ActivePlayer.Type == PlayerType.Battlebeard ? _GameStateHolder._ActivePlayer : _GameStateHolder._InactivePlayer;
        // set up the units and stuff

        activePlayer = BattlerType.None;

        // init the ui
        _BattleUnitPositionManager.Initialise(_BattlebeardPlayer, _StormshaperPlayer);

        Debug.Log(_BattleData._BattleType);

        _instigatorBattlers = new List <Unit>();
        _GameStateHolder._ActivePlayer.OnUpdateUnit += OnUpdateUnit;
        _GameStateHolder._ActivePlayer.OnAddUnit    += OnAddUnit;
        // add player event listeners
        _GameStateHolder._ActivePlayer.Initialise();

        //ui event listeners
        _BattleUnitPositionManager.OnPause         += _BattleUnitPositionManager_OnPause;
        _BattleUnitPositionManager.OnUnPause       += _BattleUnitPositionManager_OnUnPause;
        _BattleUnitPositionManager.OnPlayerUseCard += UseCard;

        _BattlebeardPlayer.OnCardAdded   += _BattlebeardPlayer_OnCardAdded;
        _BattlebeardPlayer.OnCardRemoved += _BattlebeardPlayer_OnCardRemoved;
        _StormshaperPlayer.OnCardAdded   += _StormshaperPlayer_OnCardAdded;
        _StormshaperPlayer.OnCardRemoved += _StormshaperPlayer_OnCardRemoved;

        // init the card system
        _CardSystem.RequestUnitSelection += _CardSystem_RequestUnitSelection;
        _CardSystem.OnEffectApplied      += _CardSystem_OnEffectApplied;


        if (_BattleData._BattleType == BattleType.LostImmortal)
        {
            _setupLostImmortalBattle();
            // start pre battle stuff
            StartCoroutine(_preBattle());
        }
        else if (_BattleData._BattleType == BattleType.Monster || _BattleData._BattleType == BattleType.Card)
        {
            _setupMonsterBattle();
            // start pre battle stuff
            StartCoroutine(_preBattle());
        }
        else if (_BattleData._BattleType == BattleType.PvP)
        {
            _setupPvPBattle();
            // pre battle starts inside the setup because we wait for unit selection (blargh)
        }
    }
Exemple #6
0
    public PlayerType GetPlayerTypeByBattler(BattlerType bType)
    {
        if (bType == BattlerType.Instigator)
        {
            return(_GameStateHolder._ActivePlayer.Type);
        }
        else if (_BattleData._BattleType == BattleType.PvP)
        {
            return(_GameStateHolder._InactivePlayer.Type);
        }

        return(PlayerType.None);
    }
Exemple #7
0
	// Use this for initialization
	void Start () {
		Fader.ScreenFader.StartFadeOverTime(Fader.FadeDir.FadeOut, SceneSnapshot.ScreenSnapshot.SnapScreenShot);
		// set up the players
		_StormshaperPlayer = _GameStateHolder._ActivePlayer.Type == PlayerType.Stormshaper ? _GameStateHolder._ActivePlayer : _GameStateHolder._InactivePlayer;
		_BattlebeardPlayer = _GameStateHolder._ActivePlayer.Type == PlayerType.Battlebeard ? _GameStateHolder._ActivePlayer : _GameStateHolder._InactivePlayer;
		// set up the units and stuff

		activePlayer = BattlerType.None;
		_BattleData._LostUnit = null;

		// init the ui
		_BattleUnitPositionManager.Initialise(_BattlebeardPlayer, _StormshaperPlayer);

		Debug.Log(_BattleData._BattleType);

		_instigatorBattlers = new List<Unit>();
		_GameStateHolder._ActivePlayer.OnUpdateUnit += OnUpdateUnit;
		_GameStateHolder._ActivePlayer.OnAddUnit += OnAddUnit;
		// add player event listeners
		_GameStateHolder._ActivePlayer.Initialise();

        //ui event listeners
        _BattleUnitPositionManager.OnPause += _BattleUnitPositionManager_OnPause;
        _BattleUnitPositionManager.OnUnPause += _BattleUnitPositionManager_OnUnPause;
		_BattleUnitPositionManager.OnPlayerUseCard += UseCard;

		_BattlebeardPlayer.OnCardAdded += _BattlebeardPlayer_OnCardAdded;
		_BattlebeardPlayer.OnCardRemoved += _BattlebeardPlayer_OnCardRemoved;
		_StormshaperPlayer.OnCardAdded += _StormshaperPlayer_OnCardAdded;
		_StormshaperPlayer.OnCardRemoved += _StormshaperPlayer_OnCardRemoved;

		// init the card system
		_CardSystem.RequestUnitSelection += _CardSystem_RequestUnitSelection;
		_CardSystem.OnEffectApplied += _CardSystem_OnEffectApplied;


		if (_BattleData._BattleType == BattleType.LostImmortal) {
			_setupLostImmortalBattle();
			// start pre battle stuff
			StartCoroutine(_preBattle());
		}
		else if (_BattleData._BattleType == BattleType.Monster || _BattleData._BattleType == BattleType.Card) {
			_setupMonsterBattle();
			// start pre battle stuff
			StartCoroutine(_preBattle());
		}
		else if (_BattleData._BattleType == BattleType.PvP) {
			_setupPvPBattle();
			// pre battle starts inside the setup because we wait for unit selection (blargh)
		}		
	}
Exemple #8
0
    void calculateFirstTurnNonPvP()
    {
        // calculate speeds

        CardData activeCard = _GameStateHolder._ActivePlayer.GetCardOfType(CardType.Priority_Card);

        if (activeCard != null)
        {
            _GameStateHolder._ActivePlayer.RemoveCard(activeCard);
            activePlayer = BattlerType.Instigator;
        }
        else
        {
            float maxSpeedInstigator = _instigatorBattlers.Max(x => x.GetSpeed());
            float maxSpeedOpposition = _oppositionBattler.GetSpeed();

            // if now get the chance that the instigator will go first
            float chance = 0;
            if (maxSpeedInstigator >= maxSpeedOpposition)
            {
                chance = 1 - getPercentage(maxSpeedOpposition, maxSpeedInstigator);
            }
            else if (maxSpeedOpposition > maxSpeedInstigator)
            {
                chance = getPercentage(maxSpeedInstigator, maxSpeedOpposition);
            }
            if (new System.Random().NextDouble() < chance)
            {
                activePlayer = BattlerType.Instigator;
            }
            else
            {
                activePlayer = BattlerType.Opposition;
            }
        }
        Debug.Log(activePlayer + " goes first");
    }
 void BattlerDied(BattleBehavior battler, BattlerType type)
 {
     StartCoroutine(DeathRoutine(battler, type));
 }
Exemple #10
0
 void switchPlayer()
 {
     activePlayer = (activePlayer == BattlerType.Instigator) ? BattlerType.Opposition : BattlerType.Instigator;
     startTurn();
 }
	// attack
	public void Attack(BattlerType attacker) {
		if(attacker == BattlerType.Instigator) {
			if (_BattleManager._BattleData._BattleType == BattleType.PvP) {
				_InstigatorPlayerUnit.gameObject.GetComponentInChildren<Animator>().SetTrigger("Attack");
			} else {
				foreach(GameObject g in _ActivePlayerUnits) {
					if (g != null) {
						g.gameObject.GetComponentInChildren<Animator>().SetTrigger("Attack");
					}
				}
			}	
			_ActiveOpposition.gameObject.GetComponentInChildren<Animator>().SetTrigger("Hit");
		}
		else {
			_ActiveOpposition.gameObject.GetComponentInChildren<Animator>().SetTrigger("Attack");
			_InstigatorPlayerUnit.gameObject.GetComponentInChildren<Animator>().SetTrigger("Hit");
		}
	}
 //For when a character or enemy dies
 IEnumerator DeathRoutine(BattleBehavior battler, BattlerType type)
 {
     wait = true;
     if (type == BattlerType.Character)
     {
         yield return battler.CharacterDie();
     }
     else if (type == BattlerType.Enemy)
     {
         yield return battler.EnemyDie();
     }
     wait = false;
 }
	public void HideChest(BattlerType t) {
		if (t == BattlerType.Instigator) {
			_TreasureChestInstigator.SetActive(false);
		} else {
			_TreasureChestOpposition.gameObject.SetActive(false);
		}
	}
Exemple #14
0
	public PlayerType GetPlayerTypeByBattler(BattlerType bType)
	{
		if (bType == BattlerType.Instigator) {
			return _GameStateHolder._ActivePlayer.Type;
		} else if (_BattleData._BattleType == BattleType.PvP){
			return _GameStateHolder._InactivePlayer.Type;
		}

		return PlayerType.None;
	}
Exemple #15
0
	public int Attack(BattlerType t, iBattleable target) {
		int totalDamage = 0;
		if (t == BattlerType.Instigator) {
			totalDamage = _instigatorBattlers.Sum(x => x.GetStrength());
			Audio.AudioInstance.PlaySFX(_instigatorBattlers[0].GetAttackSound());
		}
		else {
			totalDamage = _oppositionBattler.GetStrength();
			Audio.AudioInstance.PlaySFX(_oppositionBattler.GetAttackSound());
		}
		target.ReduceHP(totalDamage);
		OnBattleAbleTakeDamage (target, totalDamage);
		OnBattleAbleUpdate (target);

		if (target.IsKO()) {
			Audio.AudioInstance.PlaySFX(target.GetDeathSound());
		} else {
			Audio.AudioInstance.PlaySFX(target.GetHitSound());
		}

		Debug.Log(t + " attacked " + target.GetType() + " for " + totalDamage + " damage.");
		Debug.Log(target.GetCurrentHP() + " hp left (" + target.GetHPPercentage()*100 + "%)");
		return totalDamage;
	}
Exemple #16
0
	void switchPlayer() {
		activePlayer = (activePlayer == BattlerType.Instigator) ? BattlerType.Opposition : BattlerType.Instigator;
		startTurn();
	}
Exemple #17
0
	void calculateFirstTurnNonPvP() {
		// calculate speeds

		CardData activeCard = _GameStateHolder._ActivePlayer.GetCardOfType(CardType.Priority_Card);
		if (activeCard != null) {
			_GameStateHolder._ActivePlayer.RemoveCard(activeCard);
			activePlayer = BattlerType.Instigator;
		} else {
			float maxSpeedInstigator = _instigatorBattlers.Max(x => x.GetSpeed());
			float maxSpeedOpposition = _oppositionBattler.GetSpeed();

			// if now get the chance that the instigator will go first
			float chance = 0;
			if(maxSpeedInstigator >= maxSpeedOpposition) {
				chance = 1 - getPercentage(maxSpeedOpposition, maxSpeedInstigator);
			}
			else if(maxSpeedOpposition > maxSpeedInstigator) {
				chance = getPercentage(maxSpeedInstigator, maxSpeedOpposition);
			}
			if(new System.Random().NextDouble() < chance) {
				activePlayer = BattlerType.Instigator;
			}
			else {
				activePlayer = BattlerType.Opposition;
			}
		}
		Debug.Log(activePlayer + " goes first");
	}
Exemple #18
0
	void calculateFirstTurnPvP() {
		// calculate who goes first
		CardData activeCard = _GameStateHolder._ActivePlayer.GetCardOfType(CardType.Priority_Card),
				 inactiveCard = _GameStateHolder._InactivePlayer.GetCardOfType(CardType.Priority_Card);

		if (activeCard != null ^ inactiveCard != null) {
			// one player has a priority card, which one?
			if (inactiveCard != null) {
				activePlayer = BattlerType.Opposition;
				_GameStateHolder._InactivePlayer.RemoveCard(inactiveCard);
				Debug.Log(_GameStateHolder._InactivePlayer.GetType() + " used priority card to go first");
			} else {
				activePlayer = BattlerType.Instigator;
				_GameStateHolder._ActivePlayer.RemoveCard(activeCard);
				Debug.Log(_GameStateHolder._ActivePlayer.GetType() + " used priority card to go first");
			}
		}
		else {
			calculateFirstTurnNonPvP();
		}
	}