コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (Target != null)
        {
            timer -= Time.deltaTime;
            if (timer <= 0)
            {
                if (turn == true)
                {
                    if (counter >= thisAttack)
                    {
                        if (enemyCounter >= Target.GetComponent <Attack>().thisAttack)
                        {
                            Target = null;

                            if (GetComponent <Unit>().controlledByAI == true)
                            {
                                GetComponent <Unit>().AIOverlord.GetComponent <Tracker>().NextUnit();
                            }

                            return;
                        }
                        turn = false;
                        return;
                    }
                    Att(Target, thisDamage, EnemyDef);
                    turn = false;
                    counter++;
                    timer = 1.0f;
                }
                else if (turn == false)
                {
                    if (enemyCounter >= Target.GetComponent <Attack>().thisAttack)
                    {
                        turn = true;
                        return;
                    }
                    Target.GetComponent <Attack>().Att(GetComponent <HitPoints>(), Target.GetComponent <Attack>().thisDamage, CurrentDef);
                    turn = true;
                    enemyCounter++;

                    timer = 1.0f;
                }
            }
        }
    }