Beispiel #1
0
 // Update is called once per frame
 void Update()
 {
     if (isTargeting)
     {
         if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))
         {
             if (target == 0)
             {
                 target = Constants.MAX_ENEMIES - 1;
             }
             else if (target != Constants.MAX_ENEMIES)
             {
                 target -= 1;
             }
             UpdateTarget(-1);
         }
         else if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
         {
             if (target == Constants.MAX_ENEMIES - 1)
             {
                 target = 0;
             }
             else if (target != Constants.MAX_ENEMIES)
             {
                 target += 1;
             }
             UpdateTarget(1);
         }
         if (gameManager.AnalysisEnabled)
         {
             Monster monst = GetFirstTarget();
             if (monst == null)
             {
                 return;
             }
             gameManager.DisplayAnalysis(monst.Stats, GetMonsterByName(monst.Stats.Name));
         }
         if (IsCasting)
         {
             if (GetFirstTarget() != null)
             {
                 if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Return) || Input.GetMouseButton((int)MouseButton.LeftMouse))
                 {
                     IsCasting = false;
                     StartCoroutine(CastSkill(currentSkill, player));
                     ChangeTargeting(false);
                 }
             }
         }
     }
     if (Input.GetKeyDown(KeyCode.O))
     {
         InitTurns();
     }
     if (Input.GetKeyDown(KeyCode.P))
     {
         AdvanceTurn();
     }
     hpText.text = "HP: " + player.CurrentHealth + "/" + player.Stats.MaxHealth;
     mpText.text = "MP: " + player.CurrentMana + "/" + player.Stats.MaxMana;
 }
Beispiel #2
0
        public IEnumerator CastSkill(SkillStats skill, Unit caster)
        {
            if (caster.IsPlayer)
            {
                caster.ApplyCost(skill.Cost, skill.CostType);
                ChangeDescription("Using " + skill.NameStr);
            }
            else
            {
                ChangeDescription(caster.NameStr + " uses " + skill.NameStr);
            }
            if (caster.GetStatus() == Constants.StatusTypes.Forget && skill.CostType == Constants.CostTypes.Spell)
            {
                log.Add(caster.NameStr + " forgot how to use spells");
                AdvanceTurn();
            }
            //Guard
            if (skill.SkillType == Constants.SkillTypes.Hidden && skill.BuffType == Constants.BuffTypes.Guard)
            {
                float waitDuration = gameManager.PlayParticle(Constants.SkillTypes.Buff, Constants.MAX_ENEMIES);
                yield return(new WaitForSeconds(waitDuration * 1f));

                DoBuff(skill, caster, caster, true, Constants.MAX_ENEMIES);
            }
            else
            //Find defender(s)
            if (skill.SkillType <= Constants.SkillTypes.Dark || skill.SkillType == Constants.SkillTypes.Hidden)
            {
                float waitDuration;
                //Get Targets
                if (skill.TargetType == Constants.TargetTypes.All && caster.IsPlayer)
                {
                    for (int i = 0; i < monsters.Length; i++)
                    {
                        if (monsters[i].enabled)
                        {
                            waitDuration = gameManager.PlayParticle(skill.SkillType, i);
                            yield return(new WaitForSeconds(waitDuration / 2));

                            DoHit(skill, caster, monsters[i], caster.IsPlayer, i);
                        }
                    }
                }
                else if (skill.TargetType == Constants.TargetTypes.Single && caster.IsPlayer)
                {
                    int targetPos = GetFirstTargetPos();
                    if (targetPos != -1)
                    {
                        waitDuration = gameManager.PlayParticle(skill.SkillType, targetPos);
                        Monster target = GetFirstTarget();
                        yield return(new WaitForSeconds(waitDuration));

                        DoHit(skill, caster, target, caster.IsPlayer, targetPos);
                    }
                }
                else if (!caster.IsPlayer)
                {
                    waitDuration = gameManager.PlayParticle(skill.SkillType, Constants.MAX_ENEMIES);
                    yield return(new WaitForSeconds(waitDuration * 1f));

                    DoHit(skill, caster, player, false, Constants.MAX_ENEMIES);
                }
            }
            else if (skill.SkillType == Constants.SkillTypes.Heal)
            {
                float waitDuration;
                if (skill.TargetType == Constants.TargetTypes.All && !caster.IsPlayer)
                {
                    for (int i = 0; i < monsters.Length; i++)
                    {
                        if (monsters[i].enabled)
                        {
                            waitDuration = gameManager.PlayParticle(skill.SkillType, i);
                            yield return(new WaitForSeconds(waitDuration / 2));

                            DoHeal(skill, caster, monsters[i], caster.IsPlayer, i);
                        }
                    }
                }
                else if (skill.TargetType == Constants.TargetTypes.Single && !caster.IsPlayer)
                {
                    float[] temp = new float[Constants.MAX_ENEMIES];
                    for (int i = 0; i < monsters.Length; i++)
                    {
                        if (monsters[i].enabled)
                        {
                            temp[i] = monsters[i].CurrentHealth;
                        }
                        else
                        {
                            temp[i] = Mathf.Infinity;
                        }
                    }
                    int pos = Array.IndexOf(temp, temp.Min());
                    waitDuration = gameManager.PlayParticle(skill.SkillType, pos);
                    yield return(new WaitForSeconds(waitDuration * 1f));

                    DoHeal(skill, caster, monsters[pos], caster.IsPlayer, pos);
                }
                else
                {
                    waitDuration = gameManager.PlayParticle(skill.SkillType, Constants.MAX_ENEMIES);
                    yield return(new WaitForSeconds(waitDuration * 1f));

                    DoHeal(skill, caster, caster, true, Constants.MAX_ENEMIES);
                }
            }
            else if (skill.SkillType == Constants.SkillTypes.Break)
            {
                float waitDuration;
                if (!caster.IsPlayer)
                {
                    waitDuration = gameManager.PlayParticle(skill.SkillType, Array.IndexOf(monsters, caster));
                    yield return(new WaitForSeconds(waitDuration * 1f));
                }
                else
                {
                    waitDuration = gameManager.PlayParticle(skill.SkillType, Constants.MAX_ENEMIES);
                    yield return(new WaitForSeconds(waitDuration * 1f));
                }
                if (caster.GetStatus() == skill.StatusType)
                {
                    caster.RemoveStatus();
                    log.Add("You broke free from your status affliction");
                }
                else
                {
                    log.Add("You tried to break, but you weren't afflicted by that status");
                }
            }
            else if (skill.SkillType == Constants.SkillTypes.Status || skill.SkillType == Constants.SkillTypes.Blast)
            {
                float waitDuration;
                //Get Targets
                if (skill.TargetType == Constants.TargetTypes.All && caster.IsPlayer)
                {
                    for (int i = 0; i < monsters.Length; i++)
                    {
                        if (monsters[i].enabled)
                        {
                            waitDuration = gameManager.PlayParticle(skill.SkillType, i);
                            yield return(new WaitForSeconds(waitDuration / 2));

                            DoStatus(skill, caster, monsters[i], caster.IsPlayer, i);
                        }
                    }
                }
                else if (skill.TargetType == Constants.TargetTypes.Single && caster.IsPlayer)
                {
                    int targetPos = GetFirstTargetPos();
                    if (targetPos != -1)
                    {
                        waitDuration = gameManager.PlayParticle(skill.SkillType, targetPos);
                        Monster target = GetFirstTarget();
                        yield return(new WaitForSeconds(waitDuration * 1f));

                        DoStatus(skill, caster, target, caster.IsPlayer, targetPos);
                    }
                }
                else if (!caster.IsPlayer)
                {
                    waitDuration = gameManager.PlayParticle(skill.SkillType, Constants.MAX_ENEMIES);
                    yield return(new WaitForSeconds(waitDuration * 1f));

                    DoStatus(skill, caster, player, false, Constants.MAX_ENEMIES);
                }
            }
            else if (skill.SkillType == Constants.SkillTypes.Buff && skill.Power >= 0)
            {
                //Buff
                float waitDuration;
                if (skill.TargetType == Constants.TargetTypes.All && !caster.IsPlayer)
                {
                    for (int i = 0; i < monsters.Length; i++)
                    {
                        if (monsters[i].enabled)
                        {
                            waitDuration = gameManager.PlayParticle(skill.SkillType, i);
                            yield return(new WaitForSeconds(waitDuration / 2));

                            DoBuff(skill, caster, monsters[i], caster.IsPlayer, i);
                        }
                    }
                }
                else if (skill.TargetType == Constants.TargetTypes.Single && !caster.IsPlayer)
                {
                    float[] temp = new float[Constants.MAX_ENEMIES];
                    for (int i = 0; i < monsters.Length; i++)
                    {
                        if (monsters[i].enabled)
                        {
                            temp[i] = monsters[i].CurrentHealth;
                        }
                        else
                        {
                            temp[i] = Mathf.Infinity;
                        }
                    }
                    int pos = Array.IndexOf(temp, temp.Min());
                    waitDuration = gameManager.PlayParticle(skill.SkillType, pos);
                    yield return(new WaitForSeconds(waitDuration * 1f));

                    DoBuff(skill, caster, monsters[pos], caster.IsPlayer, pos);
                }
                else
                {
                    waitDuration = gameManager.PlayParticle(skill.SkillType, Constants.MAX_ENEMIES);
                    yield return(new WaitForSeconds(waitDuration * 1f));

                    DoBuff(skill, caster, caster, true, Constants.MAX_ENEMIES);
                }
            }
            else if (skill.SkillType == Constants.SkillTypes.Buff && skill.Power <= 0)
            {
                //Debuff
                float waitDuration;
                //Get Targets
                if (skill.TargetType == Constants.TargetTypes.All && caster.IsPlayer)
                {
                    for (int i = 0; i < monsters.Length; i++)
                    {
                        if (monsters[i].enabled)
                        {
                            waitDuration = gameManager.PlayParticle(skill.SkillType, i);
                            yield return(new WaitForSeconds(waitDuration / 2));

                            DoBuff(skill, caster, monsters[i], caster.IsPlayer, i);
                        }
                    }
                }
                else if (skill.TargetType == Constants.TargetTypes.Single && caster.IsPlayer)
                {
                    int targetPos = GetFirstTargetPos();
                    if (targetPos != -1)
                    {
                        waitDuration = gameManager.PlayParticle(skill.SkillType, targetPos);
                        Monster target = GetFirstTarget();
                        yield return(new WaitForSeconds(waitDuration * 1f));

                        DoBuff(skill, caster, target, caster.IsPlayer, targetPos);
                    }
                }
                else if (!caster.IsPlayer)
                {
                    waitDuration = gameManager.PlayParticle(skill.SkillType, Constants.MAX_ENEMIES);
                    yield return(new WaitForSeconds(waitDuration * 1f));

                    DoBuff(skill, caster, player, false, Constants.MAX_ENEMIES);
                }
            }
            else
            {
                log.Add("WIP skill");
            }
            ClearDescription();
            if (Turn != Turns.EndGame)
            {
                if (!CheckAlive())
                {
                    yield return(new WaitForSeconds(1f));

                    HideAllHealthBars();
                    rewards.GenerateRewards();
                }
                else
                {
                    if (caster.OneMore)
                    {
                        caster.OneMore = false;
                        HideOneMore();
                        if (!caster.IsPlayer)
                        {
                            MonsterCast((int)Turn - 1);
                        }
                        else
                        {
                            ChangeDescription("Knocked one down! Take another turn");
                        }
                    }
                    else
                    {
                        HideOneMore();
                        yield return(new WaitForSeconds(1f));

                        AdvanceTurn();
                    }
                }
            }
            else
            {
                ChangeDescription("You are Dead");
                yield return(new WaitForSeconds(5f));

                SceneManager.LoadScene(0);
            }
        }
Beispiel #3
0
        private void ProcessMoveAction(Monster selectedMonster, NodePath path)
        {
            selectedMonster.CurrentNode = GameGraph.Nodes[path.DestinationNode.Id];

            SubActionNumber = 0;
        }