Beispiel #1
0
    public static MyEnum.ArmyDoctrines chooseDoctrine(Nation player)
    {
        //for now it is just random - later give AI prefences based on its general military strategy
        //Make sure to check if all doctrines have been acquired before calling
        Array values = Enum.GetValues(typeof(MyEnum.ArmyDoctrines));

        System.Random random = new System.Random();
        bool          flag   = false;

        MyEnum.ArmyDoctrines randomDoct = (MyEnum.ArmyDoctrines)values.GetValue(random.Next(values.Length));
        //   Debug.Log("Randomly Chosen Doctrine: " + randomDoct);
        while (flag == false)
        {
            if (player.landForces.hasDoctrine(randomDoct))
            {
                randomDoct = (MyEnum.ArmyDoctrines)values.GetValue(random.Next(values.Length));
                continue;
            }
            else
            {
                flag = true;
            }
        }
        return(randomDoct);
    }
    private void addDoctrine()
    {
        App    app         = UnityEngine.Object.FindObjectOfType <App>();
        int    playerIndex = app.GetHumanIndex();
        Nation player      = State.getNations()[playerIndex];
        string name        = EventSystem.current.currentSelectedGameObject.name;

        Debug.Log(name);
        MyEnum.ArmyDoctrines newDoctrine = (MyEnum.ArmyDoctrines)Enum.Parse(typeof(MyEnum.ArmyDoctrines), name);
        Debug.Log(newDoctrine);
        player.landForces.addDoctrine(newDoctrine);
        uiUpdater.updateUI();
    }