Esempio n. 1
0
 void BattleManager_OnBattleAbleUpdate(iBattleable battleAbleObject)
 {
     if (_healthBarSliders.ContainsKey(battleAbleObject.GetUniqueID()))
     {
         _healthBarSliders[battleAbleObject.GetUniqueID()].value = battleAbleObject.GetHPPercentage();
     }
 }
Esempio n. 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);
    }
Esempio n. 3
0
 void BattleManager_OnBattleAbleTakeDamage(iBattleable battleAbleObject, int i)
 {
     //Animator a =
     if (battleAbleObject.IsKO())
     {
     }
 }
Esempio n. 4
0
 void BattleManager_OnBattleAbleTakeDamage(iBattleable battleAbleObject, int val)
 {
     //check that the battlable thing taking damage is associated with this ui
     if (_units.Contains(battleAbleObject))
     {
         //damage flash
         TakeDamage(val);
     }
 }
Esempio n. 5
0
 void BattleManager_OnBattleAbleTakeDamage(iBattleable battleAbleObject, int val)
 {
     //check that the battlable thing taking damage is associated with this ui
     if (_units.Contains (battleAbleObject))
     {
         //damage flash
         TakeDamage(val);
     }
 }
Esempio n. 6
0
    void setOpposition(GameObject g, iBattleable monster)
    {
        _ActiveOpposition = (GameObject)Instantiate(g, _MarkerActiveOpposition.transform.position, _MarkerActiveOpposition.transform.rotation);

        //battle unit ui
        GameObject unitUI = _UnitUIPool.GetPooledObject();

        awakenUnitUI(unitUI, _MarkerActiveOpposition, _ActiveOpposition);
        _ActiveOppositionUI = unitUI.GetComponent <BattleUnitUI>();
        _ActiveOppositionUI.AddUnit(monster);
    }
Esempio n. 7
0
    IEnumerator endTurn()
    {
        if (!(activePlayer == BattlerType.Opposition && _BattleData._BattleType != BattleType.PvP))
        {
            // do end turn stuff
            _BattleUnitPositionManager._ArmyUI.Hide();
            _BattleUnitPositionManager._HandUI.Hide();
            _BattleUnitPositionManager._ButtonsUI.Hide();
        }
        yield return(new WaitForSeconds(2));

        if (_instigatorBattlers.Count() == 0)
        {
            _endBattle(BattleEndState.Loss);
        }
        else if (_oppositionBattler.IsKO())
        {
            if (_BattleData._BattleType == BattleType.LostImmortal)
            {
                if (_oppositionReserveB != null)
                {
                    _BattleUnitPositionManager.RemoveOpposition();
                    _BattleUnitPositionManager.SetReserveBAsOpposition();
                    _oppositionBattler  = _oppositionReserveB;
                    _oppositionReserveB = null;
                    switchPlayer();
                }
                else if (_oppositionReserveC != null)
                {
                    _BattleUnitPositionManager.RemoveOpposition();
                    _BattleUnitPositionManager.SetReserveCAsOpposition();
                    _oppositionBattler  = _oppositionReserveC;
                    _oppositionReserveC = null;
                    switchPlayer();
                }
                else
                {
                    _BattleUnitPositionManager.RemoveOpposition();
                    _endBattle(BattleEndState.Win);
                }
            }
            else
            {
                _BattleUnitPositionManager.RemoveOpposition();
                _endBattle(BattleEndState.Win);
            }
        }
        else
        {
            switchPlayer();
        }
    }
Esempio n. 8
0
    public void SetReserveOppositionC(MonsterType t, iBattleable monster)
    {
        GameObject g = _Monsters[(int)t];

        _ReserveOppositionC = (GameObject)Instantiate(g, _MarkerReserveOppositionC.transform.position, _MarkerReserveOppositionC.transform.rotation);

        //battle unit ui
        GameObject unitUI = _UnitUIPool.GetPooledObject();

        awakenUnitUI(unitUI, _MarkerReserveOppositionC, _ReserveOppositionC);
        _ReserveOppositionCUI = unitUI.GetComponent <BattleUnitUI>();
        _ReserveOppositionCUI.AddUnit(monster);
    }
Esempio n. 9
0
    public void AttackButton()
    {
        if (_BattleData._BattleType != BattleType.PvP && activePlayer != BattlerType.Instigator)
        {
            return;
        }
        attacking = true;
        iBattleable target = _oppositionBattler;

        if (_BattleData._BattleType == BattleType.PvP && activePlayer != BattlerType.Instigator)
        {
            target = _instigatorBattlers[0];
        }

        Attack(activePlayer, target);
        StartCoroutine(endTurn());
    }
Esempio n. 10
0
    public void AddUnit(iBattleable unit)
    {
        if (unit == null)
            return;

        BattleManager.OnBattleAbleUpdate += BattleManager_OnBattleAbleUpdate;
        BattleManager.OnBattleAbleTakeDamage+=BattleManager_OnBattleAbleTakeDamage;

        //init a new health bar
        GameObject healthBar = _healthBarPool.GetPooledObject ();
        healthBar.SetActive (true);
        healthBar.transform.SetParent (_HealthBarDisplays.transform);
        healthBar.transform.localScale = new Vector3(1, 1, 1);
        _healthBarSliders.Add(unit.GetHashCode(), healthBar.GetComponentInChildren<Slider>());

        //refresh
        BattleManager_OnBattleAbleUpdate(unit);

        _units.Add (unit);
    }
Esempio n. 11
0
    public void AddUnit(iBattleable unit)
    {
        if (unit == null)
        {
            return;
        }

        BattleManager.OnBattleAbleUpdate     += BattleManager_OnBattleAbleUpdate;
        BattleManager.OnBattleAbleTakeDamage += BattleManager_OnBattleAbleTakeDamage;

        //init a new health bar
        GameObject healthBar = _healthBarPool.GetPooledObject();

        healthBar.SetActive(true);
        healthBar.transform.SetParent(_HealthBarDisplays.transform);
        healthBar.transform.localScale = new Vector3(1, 1, 1);
        _healthBarSliders.Add(unit.GetHashCode(), healthBar.GetComponentInChildren <Slider>());

        //refresh
        BattleManager_OnBattleAbleUpdate(unit);

        _units.Add(unit);
    }
Esempio n. 12
0
    public void SetReserveOppositionC(MonsterType t, iBattleable monster)
    {
        GameObject g = _Monsters[(int)t];
        _ReserveOppositionC = (GameObject)Instantiate(g, _MarkerReserveOppositionC.transform.position, _MarkerReserveOppositionC.transform.rotation);

        //battle unit ui 
        GameObject unitUI = _UnitUIPool.GetPooledObject();
        awakenUnitUI(unitUI, _MarkerReserveOppositionC, _ReserveOppositionC);
        _ReserveOppositionCUI = unitUI.GetComponent<BattleUnitUI>();
        _ReserveOppositionCUI.AddUnit(monster);
    }
Esempio n. 13
0
	public void SetOpposition(MonsterType t, iBattleable monster) {
        setOpposition(_Monsters[(int)t], monster);
	}
Esempio n. 14
0
	void setOpposition(GameObject g, iBattleable monster) {
	    _ActiveOpposition = (GameObject)Instantiate(g, _MarkerActiveOpposition.transform.position, _MarkerActiveOpposition.transform.rotation);

        //battle unit ui 
        GameObject unitUI = _UnitUIPool.GetPooledObject();
        awakenUnitUI(unitUI, _MarkerActiveOpposition, _ActiveOpposition);
        _ActiveOppositionUI = unitUI.GetComponent<BattleUnitUI>();
        _ActiveOppositionUI.AddUnit(monster);
	}
Esempio n. 15
0
	void BattleManager_OnBattleAbleTakeDamage(iBattleable battleAbleObject, int i) {
		//Animator a = 
		if (battleAbleObject.IsKO()) {
			
		}
	}
Esempio n. 16
0
	public void SetOpposition(UnitType t, PlayerType p, iBattleable unit) {
		List<GameObject> prefabs = p == PlayerType.Battlebeard ? _BattlebeardUnits : _StormshaperUnits;
        setOpposition(prefabs[(int)t], unit);
	}
Esempio n. 17
0
 void BattleManager_OnBattleAbleUpdate(iBattleable battleAbleObject)
 {
     if(_healthBarSliders.ContainsKey(battleAbleObject.GetUniqueID()))
         _healthBarSliders[battleAbleObject.GetUniqueID()].value = battleAbleObject.GetHPPercentage();
 }
Esempio n. 18
0
	void BattleManager_OnBattleAbleUpdate(iBattleable battleAbleObject) {

	}
Esempio n. 19
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;
	}
Esempio n. 20
0
   IEnumerator endTurn() {
	   if (!(activePlayer == BattlerType.Opposition && _BattleData._BattleType != BattleType.PvP)) {
		   // do end turn stuff
		   _BattleUnitPositionManager._ArmyUI.Hide();
		   _BattleUnitPositionManager._HandUI.Hide();
		   _BattleUnitPositionManager._ButtonsUI.Hide();
	   }
		yield return new WaitForSeconds(2);
		
		if (_instigatorBattlers.Count() == 0) {
			_endBattle(BattleEndState.Loss);
		} else if (_oppositionBattler.IsKO())  {

			if(_BattleData._BattleType == BattleType.LostImmortal) {
				if(_oppositionReserveB != null) {
					_BattleUnitPositionManager.RemoveOpposition();
					_BattleUnitPositionManager.SetReserveBAsOpposition();
					_oppositionBattler = _oppositionReserveB;
					_oppositionReserveB = null;
					switchPlayer();
				}
				else if(_oppositionReserveC != null) {
					_BattleUnitPositionManager.RemoveOpposition();
					_BattleUnitPositionManager.SetReserveCAsOpposition();
					_oppositionBattler = _oppositionReserveC;
					_oppositionReserveC = null;
					switchPlayer();
				}
				else {
					_BattleUnitPositionManager.RemoveOpposition();
					_endBattle(BattleEndState.Win);
				}
			} else {
				_BattleUnitPositionManager.RemoveOpposition();
				_endBattle(BattleEndState.Win);
			}
			
		} else {
			switchPlayer();
		}
	}
Esempio n. 21
0
 void setOpposition(MonsterType t)
 {
     _oppositionBattler = _MonsterManager.NewMonster(t);
     Audio.AudioInstance.PlaySFX(_oppositionBattler.GetAttackSound());
     _BattleUnitPositionManager.SetOpposition(t, _oppositionBattler);
 }
Esempio n. 22
0
    void setOppositionC(MonsterType t){
        _oppositionReserveC = _MonsterManager.NewMonster(t);
        _BattleUnitPositionManager.SetReserveOppositionC(t, _oppositionReserveC);
	}
Esempio n. 23
0
 void BattleManager_OnBattleAbleUpdate(iBattleable battleAbleObject)
 {
 }
Esempio n. 24
0
	void setOpposition(Unit u) {
		_BattleUnitPositionManager.SetOpposition(u.Type, _GameStateHolder._InactivePlayer.Type, u);
		_oppositionBattler = u;
	}
Esempio n. 25
0
	void setOpposition(MonsterType t) {
        _oppositionBattler = _MonsterManager.NewMonster(t);
		Audio.AudioInstance.PlaySFX(_oppositionBattler.GetAttackSound());
        _BattleUnitPositionManager.SetOpposition(t, _oppositionBattler);
		
	}
Esempio n. 26
0
 void setOppositionC(MonsterType t)
 {
     _oppositionReserveC = _MonsterManager.NewMonster(t);
     _BattleUnitPositionManager.SetReserveOppositionC(t, _oppositionReserveC);
 }
Esempio n. 27
0
    public void SetOpposition(UnitType t, PlayerType p, iBattleable unit)
    {
        List <GameObject> prefabs = p == PlayerType.Battlebeard ? _BattlebeardUnits : _StormshaperUnits;

        setOpposition(prefabs[(int)t], unit);
    }
Esempio n. 28
0
 void setOpposition(Unit u)
 {
     _BattleUnitPositionManager.SetOpposition(u.Type, _GameStateHolder._InactivePlayer.Type, u);
     _oppositionBattler = u;
 }
Esempio n. 29
0
 public void SetOpposition(MonsterType t, iBattleable monster)
 {
     setOpposition(_Monsters[(int)t], monster);
 }