Exemplo n.º 1
0
        public void Init(HeroCfg player, HeroCfg ai)
        {
            {
                var actor = CreateHero(player, PlayerDataMgr.Instance.GetMainActorId());
                actor.SetActorSide(ActorSide.blue);
                ActorSys.Instance.AddActor(actor.GetActorId(), actor);
                ActorSys.Instance.SetMainActor(actor);

                var heroEntity = actor.GetComponent <HeroEntity>();

                var heroMoveComponent = actor.gameObject.AddComponent <HeroMoveComponent>();
                var birthPosition     = GetBirthPosition(0, ActorSide.blue);
                actor.transform.position = birthPosition;

                heroEntity.MoveCmpt = heroMoveComponent;

                var path    = "Configs/fsm/PlayerHero";
                var jsonStr = ResourceSys.Instance.Load <TextAsset>(path).text;
                var fsm     = DCAnimatorToFSM.Instance.Convert(jsonStr, heroEntity.CreateDCFSMState);
                heroEntity.HeroFsm = fsm;
            }

            for (var i = 0; i < 5; i++)
            {
                var actor = CreateHero(ai, PlayerDataMgr.Instance.GenerateActorId());
                actor.SetActorSide(ActorSide.red);
                var birthPosition = GetBirthPosition(i, ActorSide.red);
                actor.transform.position = birthPosition;

                ActorSys.Instance.AddActor(actor.GetActorId(), actor);
            }

            UIManager.Instance.ShowUi <FightSceneUI>();
        }
Exemplo n.º 2
0
        public GameActor CreateHero(HeroCfg heroCfg, int actorId)
        {
            var heroPrefab = ResourceSys.Instance.Load <GameObject>(heroCfg.mPrefabPath);

            var hero = Object.Instantiate(heroPrefab, GameMain.Instance.RootTf);

            var actor = hero.GetComponent <GameActor>();

            actor.SetHeroCfg(heroCfg);
            actor.SetModel(heroCfg.mModelPath);
            actor.UpdateModel();

            hero.GetComponent <HeroEntity>().mHeroCfg = heroCfg;

            return(actor);
        }
Exemplo n.º 3
0
 public void SetHeroCfg(HeroCfg cfg)
 {
     mHeroCfg = cfg;
 }