Ejemplo n.º 1
0
 public IEnumerator Run(IBattler user, IBattler target)
 {
     //SP is checked beforehand
     Parent.stats.currentSP -= RequiredSP;
     Parent.OnStatChange();
     Vector3 StartingPos = Parent.Parent.transform.position;
     Vector3 offset = new Vector3(-2f, 0f, 0f);
     anim = Parent.Parent.GetComponent<Animator>();
     AudioSource hit = Parent.Parent.GetComponent<SoundManager>().Hit2;
     if (anim != null)
         anim.SetInteger("index", 1);
     yield return Move.MoveToPosition(Parent.Parent, target.Parent.transform.position + offset, 80f);
     if (anim != null)
         anim.SetInteger("index", 2);
     //Set animation
     yield return new WaitForSeconds(0.2f);
     float baseDamage = (user.Stats.spAttack * Power * 4) - (target.Stats.spDefense * 2);
     int baseDamage2 = new System.Random().Next((int)(baseDamage * 0.9), (int)(baseDamage * 1.1));
     target.TakeDamage(user, baseDamage2);
     hit.Play();
     yield return new WaitForSeconds(0.5f);
     if (anim != null)
         anim.SetInteger("index", 1);
     yield return Move.MoveToPosition(Parent.Parent, StartingPos, 80f);
     if (anim != null)
         anim.SetInteger("index", 0);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// User: Battler that uses the item
 /// Target: Battler that the item is used on
 /// </summary>
 /// <param name="User"></param>
 /// <param name="Target"></param>
 /// <returns></returns>
 public virtual IEnumerator Use(IBattler User, IBattler Target)
 {
     Rigidbody2D rb = Parent.Parent.GetComponent<Rigidbody2D>();
     Parent.Draw(SpriteName);
     rb.AddForce(new Vector2(0f, 0.04f));
     yield return new WaitForSeconds(2f);
     Target.RestoreHP(User, 100);
     Parent.Destroy();
 }
Ejemplo n.º 3
0
 public IEnumerator UseItem(int itemIndex, IBattler target)
 {
     Item item = Parent.Inventory[itemIndex];
     //yield return new WaitForSeconds(1);
     //StartCoroutine causes a NullReferenceException
     yield return item.ItemDef.Use(Parent, target);
     //yield return new WaitForSeconds(1);
     Parent.RemoveItem(itemIndex);
 }
Ejemplo n.º 4
0
 public void CharacterTurn(IBattler character)
 {
     currentCharacter = character;
     specialIndex = 0;
     itemIndex = 0;
     PrevMenu = BattleMenu.Main;
     MainMenu();
     UpdateMenu();
 }
Ejemplo n.º 5
0
    public void SetSelector(TargetSelector selector, IBattler battler)
    {
        currentSelector = selector;
        List <ITargetable> targets = currentSelector.Eval(battler);

        for (int i = 0; i < targets.Count; i++)
        {
            targets[i].SetTargetable();
        }
    }
Ejemplo n.º 6
0
        public IBattler GetTargetableObject(string rawTarget)
        {
            IBattler npc = level.GetCurrentLocation().TargetNpc(rawTarget);

            if (npc != null)
            {
                return(npc);
            }

            return(null);
        }
Ejemplo n.º 7
0
 //TODO: Finish
 public void TakeDamage(IBattler user, int baseDamage)
 {
     stats.currentHP -= baseDamage;
     if (stats.currentHP < 0)
     {
         stats.currentHP = 0;
     }
     if (OnDamage != null)
     {
         OnDamage(Parent, baseDamage);
     }
     Debug.Log(stats.characterName + " took " + baseDamage + " damage.");
 }
Ejemplo n.º 8
0
        private void PerformAttack(IBattler attacker, IBattler target)
        {
            if (!target.IsAlive())
            {
                Console.Write("Target is unconcious");
                return;
            }

            var hitValue = Dice.Throw(attacker.GetHitValue());

            if (target.IsHit(hitValue))
            {
                target.Injure(attacker.GetDamage());
            }
        }
Ejemplo n.º 9
0
    public List <ITargetable> Eval(IBattler b)
    {
        Player             p   = b.Owner;
        List <ITargetable> res = new List <ITargetable>();
        List <ITargetable> all = new List <ITargetable>();
        Range t = RangeMask;

        if ((t & Range.BottomSide) != 0 ||
            ((t & Range.Self) != 0 && (p.Side & BattleMaid.Turn.Self) != 0) ||
            ((t & Range.Opponent) != 0 && (p.Side & BattleMaid.Turn.Opponent) != 0))
        {
            all.AddRange(BattleMaid.Summon.GetPlayerCards(BattleMaid.Turn.Self, BattleMaid.CardState.All));
        }
        if ((t & Range.TopSide) != 0 ||
            ((t & Range.Self) != 0 && (p.Side & BattleMaid.Turn.Opponent) != 0) ||
            ((t & Range.Opponent) != 0 && (p.Side & BattleMaid.Turn.Self) != 0))
        {
            all.AddRange(BattleMaid.Summon.GetPlayerCards(BattleMaid.Turn.Opponent, BattleMaid.CardState.All));
        }
        for (int i = 0; i < all.Count; i++)
        {
            if (Judge(all[i]))
            {
                res.Add(all[i]);
            }
        }
        List <ITargetable> tauntList = new List <ITargetable>();

        if ((t & Range.IgnoreTaunt) == 0)
        {
            for (int i = 0; i < res.Count; i++)
            {
                ITargetable tar = res[i];
                if (tar.IsTaunt)
                {
                    tauntList.Add(tar);
                }
            }
            if (tauntList.Count > 0)
            {
                res = tauntList;
            }
        }
        return(result = res);
    }
Ejemplo n.º 10
0
 public IEnumerator StandardAttack(IBattler user, IBattler target)
 {
     Vector3 StartingPos = Parent.Parent.transform.position;
     Vector3 offset = new Vector3(-2f, 0f, 0f);
     anim = Parent.Parent.GetComponent<Animator>();
     AudioSource hit = Parent.Parent.GetComponent<SoundManager>().Hit;
     if (anim != null)
         anim.SetInteger("index", 1);
     yield return Move.MoveToPosition(Parent.Parent, target.Parent.transform.position + offset, 80f);
     if (anim != null)
         anim.SetInteger("index", 2);
     //Set animation
     yield return new WaitForSeconds(0.2f);
     int baseDamage = (user.Stats.attack * 4) - (target.Stats.defense * 2);
     baseDamage = new System.Random().Next((int)(baseDamage * 0.9), (int)(baseDamage * 1.1));
     target.TakeDamage(user, baseDamage);
     hit.Play();
     yield return new WaitForSeconds(0.5f);
     if (anim != null)
         anim.SetInteger("index", 1);
     yield return Move.MoveToPosition(Parent.Parent, StartingPos, 80f);
     if (anim != null)
         anim.SetInteger("index", 0);
 }
Ejemplo n.º 11
0
 public void RestoreHP(IBattler user, int health)
 {
     stats.currentHP += health;
     if (stats.currentHP > stats.maxHP)
     {
         stats.currentHP = stats.maxHP;
     }
     OnStatChange();
     OnRestoreHP(health);
 }
Ejemplo n.º 12
0
 //TODO: Finish
 public void TakeDamage(IBattler user, int baseDamage)
 {
     stats.currentHP -= baseDamage;
     if (stats.currentHP < 0)
     {
         stats.currentHP = 0;
     }
     //Send a message to the Battle UI to update the lifebar
     OnStatChange();
 }
Ejemplo n.º 13
0
 public AttackCommand(IBattler hero, IBattler enemy)
 {
     _hero  = hero;
     _enemy = enemy;
 }
Ejemplo n.º 14
0
        void _OnStart(IBattlerBehavior battle_stage)
        {
            var val = battle_stage.QueryBattler();
            val.OnValue += (battler) =>
            {
                _Binder.Bind<IBattler>(battler);
                _Battler = battler;
            };

            battle_stage.SpawnReadyCaptureEnergyEvent += (obj) =>
            {
                _Binder.Bind<IReadyCaptureEnergy>(obj);

                battle_stage.UnspawnReadyCaptureEnergyEvent+= () =>
                {
                    _Binder.Unbind<IReadyCaptureEnergy>(obj);
                };
            };
            battle_stage.SpawnCaptureEnergyEvent += (obj) =>
            {
                _Binder.Bind<ICaptureEnergy>(obj);

                battle_stage.UnspawnCaptureEnergyEvent += () =>
                {
                    _Binder.Unbind<ICaptureEnergy>(obj);
                };
            };
            battle_stage.SpawnDrawChipEvent += (obj) =>
            {
                _Binder.Bind<IDrawChip>(obj);

                battle_stage.UnspawnDrawChipEvent+= () =>
                {
                    _Binder.Unbind<IDrawChip>(obj);
                };
            };
            battle_stage.SpawnEnableChipEvent += (obj) =>
            {
                _Binder.Bind<IEnableChip>(obj);

                battle_stage.UnspawnEnableChipEvent+= () =>
                {
                    _Binder.Unbind<IEnableChip>(obj);
                };
            };
        }
Ejemplo n.º 15
0
    public IEnumerator PerformAction(IBattler battler, ActionType ActionType, int index, IBattler target)
    {
        switch (ActionType)
        {
            case ActionType.Attack:
                yield return StartCoroutine(battler.BattleBehavior.StandardAttack(battler, target));
                break;

            case ActionType.Special:
                yield return StartCoroutine(battler.BattleBehavior.SpecialActions[index].Run(battler, target));
                break;

            case ActionType.Item:
                Item item = battler.Inventory[index];
                GameObject emptyItem = Instantiate(EmptyItem, battler.Parent.transform.position, Quaternion.identity) as GameObject;
                item.Parent = emptyItem;
                StartCoroutine(item.ItemDef.FadeIn());
                yield return StartCoroutine(battler.BattleBehavior.UseItem(index, target));
                //Is "StartCoroutine()" needed?
                //yield return battler.BattleBehavior.UseItem(index, target);
                break;

            case ActionType.Defend:
                break;
        }
    }
Ejemplo n.º 16
0
 public static void EdStandardAttack(IBattler user, IBattler enemy)
 {
     int baseDamage = (user.Stats.attack * 4) - (enemy.Stats.defense * 2);
     baseDamage = new System.Random().Next((int)(baseDamage * 0.9), (int)(baseDamage * 1.1));
     enemy.TakeDamage(user, baseDamage);
 }
Ejemplo n.º 17
0
 public void RestoreHP(IBattler user, int health)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 18
0
 public override IEnumerator Use(IBattler user, IBattler target)
 {
     yield return base.Use(user, target);
 }