コード例 #1
0
    void TestReachCity()
    {
        int cIdx = pathfinding.GetCityIndex(transform.position, 5);

        if (cIdx == -1)
        {
            return;
        }

        int kIdx = Informations.Instance.GetCityInfo(cIdx).king;

        if (kIdx != -1 && kIdx != king && state != ArmyState.Escape)
        {
            AttackCity(cIdx);
            return;
        }

        if (route.Count == 0)
        {
            if (Informations.Instance.GetCityInfo(cIdx).king != king)
            {
                AttackCity(cIdx);
                return;
            }

            IntoTheCity(cIdx);
        }
    }
コード例 #2
0
    void ArmyAct(int i)
    {
        ArmyInfo armyInfo = Informations.Instance.armys[i];

        if (armyInfo.king != Controller.kingIndex && armyInfo.armyCtrl.GetState() == ArmyController.ArmyState.Garrison)
        {
            int cityCanIntoIdx = pathfinding.GetCityIndex(armyInfo.armyCtrl.transform.position, 30);
            if (cityCanIntoIdx != -1)
            {
                armyInfo.armyCtrl.IntoTheCity(cityCanIntoIdx);
            }
        }
    }
コード例 #3
0
    public void SetArmyInfo(ArmyInfo a)
    {
        armyInfo = a;

        gameObject.SetActive(true);

        infoCtrl.SetArmy(armyInfo);

        if (armyInfo.king == Controller.kingIndex)
        {
            for (int i = 0; i < commands.Length; i++)
            {
                commands[i].SetButtonEnable(true);
            }

            if (armyInfo.prisons.Count > 0)
            {
                commands[3].SetButtonEnable(true);
            }
            else
            {
                commands[3].SetButtonEnable(false);
            }

            Vector3 pos = armyInfo.armyCtrl.transform.position;
            cityCanIntoIdx = path.GetCityIndex(pos, 30);
            if (cityCanIntoIdx != -1)
            {
                if (Informations.Instance.GetCityInfo(cityCanIntoIdx).king == armyInfo.king)
                {
                    commands[4].SetButtonEnable(true);
                }
                else
                {
                    commands[4].SetButtonEnable(false);
                }
            }
            else
            {
                commands[4].SetButtonEnable(false);
            }
        }
        else
        {
            for (int i = 0; i < commands.Length; i++)
            {
                commands[i].SetButtonEnable(false);
            }
        }
    }