public void StrategyAction(Player activePlayer, Party myParty, Party enemyParty)
    {
        // 能動側が戦士の時
        if (activePlayer is Fighter)
        {
            activePlayer.Attack(activePlayer, enemyParty.AttackTarget());
            return;
        }

        // 能動側が魔術師の時
        if (activePlayer is Wizard)
        {
            //攻撃
            activePlayer.Attack(activePlayer, enemyParty.AttackTarget());
            return;
        }

        if (activePlayer is Priest)
        {
            // 能動側が僧侶の時
            if (myParty.HealMembers(20).Count > 0)
            {
                // 回復する味方がいるとき
                if (activePlayer.HealHP(activePlayer, myParty.HealMembers(20)))
                {
                    // 回復魔法を書けることができたとき
                    return;
                }
            }

            activePlayer.Attack(activePlayer, enemyParty.AttackTarget());
            return;
        }

        // 能動側が勇者の時
        if (activePlayer is Hero)
        {
            if (myParty.HealMembers(20).Count > 0)
            {
                if (activePlayer.HealHP(activePlayer, myParty.HealMembers(20)))
                {
                    // 回復魔法をかける
                    return;
                }
            }

            activePlayer.Attack(activePlayer, enemyParty.AttackTarget());
            return;
        }
    }
Exemple #2
0
    public void StrategyAction(Player activePlayer, Party myParty, Party enemyParty)
    {
        Debug.Log("DefaultStrategy StrategyAction");
        // 能動側が戦士の時
        if (activePlayer is Fighter)
        {
            activePlayer.Attack(activePlayer, enemyParty.AttackTarget());
            Debug.Log("DefaultStrategy Fighter Attack");
            return;
        }

        // 能動側が魔術師の時
        if (activePlayer is Wizard)
        {
            //攻撃
            activePlayer.Attack(activePlayer, enemyParty.AttackTarget());
            Debug.Log("DefaultStrategy Wizard");
            return;
        }

        // 能動側が僧侶の時
        if (activePlayer is Priest)
        {
            Debug.Log("DefaultStrategy Priest");
            if (myParty.DebuffMembers().Count > 0)
            {
                Debug.Log("DefaultStrategy 自身のPartyに状態異常のPlayerがいる");
                if (activePlayer.HealDebuff(activePlayer, myParty.DebuffMembers()[0]))
                {
                    Debug.Log("DefaultStrategy Priest HealDebuff");
                    return;
                }
            }

            // 回復する味方がいるとき
            if (myParty.HealMembers(50).Count > 0)
            {
                Debug.Log("DefaultStrategy 回復魔法を書けることができたとき");
                // 回復魔法を書けることができたとき
                if (activePlayer.HealHP(activePlayer, myParty.HealMembers(50)))
                {
                    Debug.Log("DefaultStrategy Priest HealHP");
                    return;
                }
            }

            if (myParty.DebuffMembers().Count > 0)
            {
                Debug.Log("DefaultStrategy 状態異常魔法をかけられる敵がいるとき");
                // 状態異常魔法をかけられる敵がいるとき
                Player passivePlayer = myParty.DebuffMembers()[UnityEngine.Random.Range(0, myParty.DebuffMembers().Count - 1)];
                if (activePlayer.Debuff(activePlayer, passivePlayer))
                {
                    Debug.Log("DefaultStrategy Priest Debuff");
                    return;
                }
            }

            Debug.Log("DefaultStrategy Priest Attack");
            activePlayer.Attack(activePlayer, enemyParty.AttackTarget());

            return;
        }

        // 能動側が勇者の時
        if (activePlayer is Hero)
        {
            Debug.Log("DefaultStrategy Hero");
            if (myParty.HealMembers(50).Count > 0)
            {
                if (activePlayer.HealHP(activePlayer, myParty.HealMembers(50)))
                {
                    // 回復魔法をかける
                    Debug.Log("DefaultStrategy Hero HealHP");
                    return;
                }
            }
            activePlayer.Attack(activePlayer, enemyParty.AttackTarget());
            Debug.Log("DefaultStrategy Hero Attack");
            return;
        }
    }
    public void NextTurn()
    {
        Debug.Log("GameManager NextTurn ");



        // ==================================================
        // バトル処理
        // ==================================================

        LogText.AddLog(string.Format("- ターン{0} -{1}", turnNumber, System.Environment.NewLine));
        this.phaseNumber = 0;


        // 行動できる人間がいる間繰り返す
        while (0 < partyMembers.FastestMembers().Count + enemyMembers.FastestMembers().Count)
        {
            // Debug用
            Debug.Log("パーティーのメンバー確認");
            foreach (Player p in this.partyMembers.GetMembers())
            {
                Debug.Log(p.GetName());
            }
            Debug.Log("エネミーのメンバー確認");
            foreach (Player p in this.enemyMembers.GetMembers())
            {
                Debug.Log(p.GetName());
            }

            Debug.Log(string.Format("{0}={1}({2} + {3})", this.phaseNumber, partyMembers.FastestMembers().Count + enemyMembers.FastestMembers().Count, partyMembers.FastestMembers().Count, enemyMembers.FastestMembers().Count));

            // 未行動のプレイヤーで一番AGIが高いプレイヤーが攻撃する
            Player attacker = ComparateAGI(phaseNumber);

            // Debug用
            Debug.Log("パーティーのメンバー確認");
            foreach (Player p in this.partyMembers.GetMembers())
            {
                Debug.Log(p.GetName());
            }
            Debug.Log("エネミーのメンバー確認");
            foreach (Player p in this.enemyMembers.GetMembers())
            {
                Debug.Log(p.GetName());
            }

            // 攻撃するプレイヤーの攻撃できる対象を決める
            Party TargetParty = ContainsParty(attacker);

            Debug.Log(attacker.GetName());

            // paralyzeTurn 0 の時
            if (attacker.GetParalyzeTurn() == 0 && attacker.isParalyze())
            {
                Debug.Log("GameManager NextTurn 麻痺がとける時");
                LogText.AddLog(string.Format("{0} の麻痺がとれた!\n", attacker.GetName()));
                attacker.RecoveryParalyze();
            }

            LogText.AddLog(string.Format("▼ {0} の行動\n", attacker.GetName()));

            // 麻痺状態でない場合の処理
            if (!attacker.isParalyze())
            {
                Debug.Log("GameManager NextTurn 麻痺になってないとき");

                //どちらのパーティーに所属しているか
                if (enemyMembers.isExists(attacker))
                {
                    Debug.Log(string.Format("{0} は敵パーティーに所属している", attacker.GetName()));
                    attacker.Action(attacker, partyMembers);
                }
                else
                {
                    Debug.Log(string.Format("{0} は味方パーティーに所属している", attacker.GetName()));
                    attacker.Action(attacker, enemyMembers);
                }
            }
            else
            {
                Debug.Log("GameManager NextTurn 麻痺になっているとき");
                LogText.AddLog(string.Format("{0} は身体が麻痺して動けない!\n", attacker.GetName()));
            }

            if (TargetParty.isLose())
            {
                if (TargetParty == enemyMembers)
                {
                    this.battleResult = 1;
                }
                else
                {
                    this.battleResult = 2;
                }
                return;
            }

            if (attacker.isPoison())
            {
                Debug.Log("GameManager NextTurn 毒状態の時");
                attacker.ProcessPoison();
            }

            // 全滅してるかどうか
            // してたらゲーム終了
            if (TargetParty.isLose())
            {
                if (TargetParty == enemyMembers)
                {
                    this.battleResult = 0;
                }
                else
                {
                    this.battleResult = 1;
                }
            }


            attacker.ChangeActive(false);
            Debug.Log(string.Format("GameManager NextTurn ChangeActive : {0}", attacker.isActive()));
            attacker.ChangeParalyzeTurn();
            Debug.Log("GameManager NextTurn ChangeParalyzeTurn");
            LogText.AddLog("--------------------------------");
            this.phaseNumber++;
        }

        LogText.AddLog("=================================");

        // ターン終了時の処理
        foreach (Player p in enemyMembers.AttackTarget())
        {
            p.ChangeActive(true);
        }

        foreach (Player p in partyMembers.AttackTarget())
        {
            p.ChangeActive(true);
        }

        StatusReflection();

        logtext.text = LogText.GetLog();
        turnNumber++;
    }
Exemple #4
0
    public void StrategyAction(Player activePlayer, Party myParty, Party enemyParty)
    {
        // 能動側が戦士の時
        if (activePlayer is Fighter)
        {
            activePlayer.Attack(activePlayer, enemyParty.AttackTarget());
            return;
        }

        // 能動側が魔術師の時
        if (activePlayer is Wizard)
        {
            //攻撃
            activePlayer.Attack(activePlayer, enemyParty.AttackTarget());
            return;
        }

        if (activePlayer is Priest)
        {
            // 能動側が僧侶の時

            if (myParty.DebuffMembers().Count > 0)
            {
                if (activePlayer.HealDebuff(activePlayer, myParty.DebuffMembers()[0]))
                {
                    return;
                }
            }
            // 回復する味方がいるとき
            if (myParty.HealMembers(90).Count > 0)
            {
                // 回復魔法を書けることができたとき
                if (activePlayer.HealHP(activePlayer, myParty.HealMembers(90)))
                {
                    return;
                }
            }

            if (myParty.DebuffMembers().Count > 0)
            {
                // 状態異常魔法をかけられる敵がいるとき
                Player passivePlayer = myParty.DebuffMembers()[UnityEngine.Random.Range(0, myParty.DebuffMembers().Count - 1)];

                if (activePlayer.Debuff(activePlayer, passivePlayer))
                {
                    return;
                }
            }



            activePlayer.Attack(activePlayer, enemyParty.AttackTarget());
            return;
        }

        // 能動側が勇者の時
        if (activePlayer is Hero)
        {
            if (myParty.HealMembers(90).Count > 0)
            {
                if (activePlayer.HealHP(activePlayer, myParty.HealMembers(90)))
                {
                    // 回復魔法をかける
                    return;
                }
            }

            activePlayer.Attack(activePlayer, enemyParty.AttackTarget());
            return;
        }
    }