Пример #1
0
    internal void MoveUnitIntoGroup(UnitGroup unit, GameObject groupGameObject)
    {
        MindGroup oldGroup = null;
        MindGroup newGroup = null;

        foreach (var group in mindGroupList)
        {
            if (group.UnitExists(unit))
            {
                oldGroup = group;
            }
            if (group.Equals(groupGameObject))
            {
                newGroup = group;
            }
        }

        if (oldGroup.Equals(newGroup))
        {
            oldGroup.UpdateLayout();
            return;
        }

        oldGroup.RemoveUnit(unit);
        newGroup.AddUnit(unit);
    }
Пример #2
0
        public IEnumerator GetsCorrectMind(bool atBase, bool updatedMinds)
        {
            bool       valid         = true;
            MindGroup  mindGroup     = unitControl.MindGroupList.GetMindGroupFromIndex(1);
            var        Id            = mindGroup.AddUnit(new UnitGroup(uiController.unitIconBase));
            GameObject gameObjectAnt = MonoBehaviour.Instantiate(Resources.Load("Prefabs/WorkerAnt") as GameObject);
            Ant        ant           = gameObjectAnt.GetComponent <Ant>();

            ant.SetunitGroupID(Id);
            ant.SetAtBase(atBase);
            yield return(new WaitForSeconds(0.01f));

            if (ant.GetMinds().Count < 1)
            {
                valid = false;
            }
            if (valid)
            {
                for (int i = 0; i < mindGroup.Minds.Count; i++)
                {
                    if (!MindEquals(mindGroup.Minds[i], ant.GetMinds()[i]))
                    {
                        valid = false;
                    }
                }
            }
            //put atbase at false so it does not try to access a disposed unitcontroller
            ant.SetAtBase(false);
            Assert.True(valid == updatedMinds);
        }
Пример #3
0
    public void UI_OpenMindBuilder(int i)
    {
        mindBuilderPanel.SetActive(true);
        currentOpenMindGroup = unitController.GetMindGroup(i);
        var MBtabbed = mindBuilderPanel.GetComponent <MindBuilderTabbed>();

        MBtabbed.mindGroup = currentOpenMindGroup;
        MBtabbed.GenerateMind();
    }
Пример #4
0
        public void UpdateResourceMindCorrectly(ResourceType resType, int carryweight, Direction exploreDirection, bool isScout = false)
        {
            MindGroup mindGroup = unitControl.MindGroupList.GetMindGroupFromIndex(1);
            Gathering gather    = new Gathering();

            for (int i = 0; i < mindGroup.Minds.Count; i++)
            {
                if (mindGroup.Minds[i].GetType() == typeof(Gathering))
                {
                    gather = (Gathering)mindGroup.Minds[i];
                }
            }
            uiController.UI_OpenMindBuilder(1);
            MindBuilderTabbed mbTabbed = uiController.GetComponentInChildren <MindBuilderTabbed>();

            mbTabbed.UpdateResourceValues(carryweight, isScout, resType, exploreDirection);
            mbTabbed.UpdateMind();

            Assert.True(MindEquals(gather, new Gathering(resType, carryweight, exploreDirection, isScout)));
        }
Пример #5
0
        public IEnumerator Init()
        {
            AsyncOperation asyncLoadLevel = SceneManager.LoadSceneAsync("TestScene", LoadSceneMode.Single);

            while (!asyncLoadLevel.isDone)
            {
                yield return(null);
            }
            uiController = GameObject.FindObjectOfType <UiController>();

            GameObject gameObjectAnt = MonoBehaviour.Instantiate(Resources.Load("Prefabs/WorkerAnt") as GameObject);

            ant = gameObjectAnt.GetComponent <Ant>();
            yield return(null);

            Gathering gather = new Gathering(ResourceType.Crystal, 1, Gathering.Direction.South, true);

            gather.state = Gathering.State.Idle;
            ant.SetMinds(new List <IMind>()
            {
                gather
            });
            foreach (IMind mind in ant.GetMinds())
            {
                mind.Initiate(ant);
            }
            MindGroup mindGroup = GameObject.FindObjectOfType <UnitController>().MindGroupList.GetMindGroupFromIndex(1);

            mindGroup.Minds = new List <IMind>()
            {
                gather
            };
            var Id = mindGroup.AddUnit(new UnitGroup(uiController.unitIconBase));

            ant.SetunitGroupID(Id);
            resource = MonoBehaviour.Instantiate(Resources.Load("Prefabs/Resources/crystal") as GameObject);
            resource.transform.position = new Vector3(0, 0.6f, 0);
            resource.GetComponent <ResourceNode>().Discover(ant.TeamID);
            resourceNode = resource.GetComponent <ResourceNode>();
        }
Пример #6
0
        public IEnumerator Init()
        {
            AsyncOperation asyncLoadLevel = SceneManager.LoadSceneAsync("TestScene", LoadSceneMode.Single);

            while (!asyncLoadLevel.isDone)
            {
                yield return(null);
            }
            uiController = GameObject.FindObjectOfType <UiController>();
            unitControl  = GameObject.FindObjectOfType <UnitController>();

            GameObject gameObjectAnt = MonoBehaviour.Instantiate(Resources.Load("Prefabs/WorkerAnt") as GameObject);

            ant = gameObjectAnt.GetComponent <Ant>();
            yield return(null);

            Gathering gather = new Gathering(ResourceType.Crystal, 1, Gathering.Direction.South, true)
            {
                state = Gathering.State.Scouting,
                busy  = true
            };

            ant.SetMinds(new List <IMind>()
            {
                gather, new CombatMind()
            });
            foreach (IMind mind in ant.GetMinds())
            {
                mind.Initiate(ant);
            }
            MindGroup mindGroup = unitControl.MindGroupList.GetMindGroupFromIndex(1);

            mindGroup.Minds = new List <IMind>()
            {
                gather, new CombatMind()
            };
            var Id = mindGroup.AddUnit(new UnitGroup(uiController.unitIconBase));

            ant.SetunitGroupID(Id);
        }
Пример #7
0
 public void UI_CloseMindBuilder()
 {
     currentOpenMindGroup = null;
     mindBuilderPanel.SetActive(false);
 }
Пример #8
0
 public bool Equals(MindGroup other)
 {
     return(UIUnitGroup.Equals(other.UIUnitGroup));
 }