コード例 #1
0
        // create new hero
        protected void CreateHero(Controller owner, int index)
        {
            SpawnPoint sp = GetBestSpawnPoint(owner.team.teamIndex);

            if (sp == null)
            {
                return;
            }

            GameObject Obj = ObjectPoolManager.instance.Pop(DataController.instance.GetDefaultHero(), sp.transform.position);

            Obj.name = "hero_" + index;

            var hero = Obj.GetComponent <Hero>();

            owner.AddHero(Obj);
            hero.SetOwner(owner);
            hero.SetPosition(sp.position);

            // {{ @Test
            HeroInfo info = new HeroInfo();

            info.name = "name" + Obj.name;
            for (int i = 0; i < 9; ++i)
            {
                info.soldiers[i] = Random.Range(0, 2);
            }
            // }} @Test
            hero.InitializeFromInfo(info);
        }
コード例 #2
0
        // initialize from info
        public void InitializeFromInfo(HeroInfo info)
        {
            if (info == null)
            {
                return;
            }

            // set name
            name = info.name;

            squad.MoveTo(position);

            // add soldiers
            for (int i = 0; i < info.soldiers.Length; ++i)
            {
                squad.SetMembers(i, DataController.CreateSoliderById(info.soldiers[i]));
            }

            squad.UpdateSquadFormation();
            squad.UpdateMembersRotation();
            squad.UpdateMembersPosition();
        }