コード例 #1
0
        private CreatureOldLogic CreateLogic(CreatureInfo info)
        {
            var logic = factory.CreateLogic(info);

            creaturesDic.Add(logic.Info.id, logic);
            return(logic);
        }
コード例 #2
0
 public MonsterLogic(CreatureInfo info) : base(info)
 {
     MonsterState = new MonsterState()
     {
         PhysicalAttackRange = new IntRange(1, 3)
     };
 }
コード例 #3
0
        public CreatureOldLogic Load(CreatureInfo info)
        {
            info.id = idGenerator++;
            var logic = CreateLogic(info);
            var view  = CreateView(info);

            logic.SetView(view);
            return(logic);
        }
コード例 #4
0
        public CreatureView CreateView(CreatureInfo info)
        {
            CreatureView view;

            switch (info.type)
            {
            case CreaturesType.Monsters:
            {
                GameObject instance = null;
                switch (info.party)
                {
                case CreaturesParty.Player:
                    instance = GameObject.Instantiate(GameEntry.Creatures.PlayerMonsterTemplate, GameEntry.Creatures.transform);
                    break;

                case CreaturesParty.Enemy:
                    instance = GameObject.Instantiate(GameEntry.Creatures.EnemyMonsterTemplate, GameEntry.Creatures.transform);
                    break;

                default:
                    throw new InvalidOperationException("没有这种阵营");
                }

                var monsterView = instance.GetOrAddComponent <MonsterView>();
                view = monsterView;

                monsterView.MonsterUI = GameObject.Instantiate(GameEntry.Creatures.MonsterUITemplate, GameEntry.Creatures.transform).GetComponent <MonsterHUD>();
                monsterView.MonsterUI.transform.rotation = Quaternion.identity;
                monsterView.MonsterUI.gameObject.AddComponent <TragetTracker>().Target = monsterView.Bindings.MonsterUIPoint;
                var sprite = GameEntry.Config.sprite.GetMonsterSprite(info.entryId);
                try
                {
                    view.Bindings.mainRenderer.sprite = sprite;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            break;

            case CreaturesType.Player:
            {
                var instance = GameObject.Instantiate(GameEntry.Creatures.PlayerTemplate, GameEntry.Creatures.transform);
                view = instance.GetOrAddComponent <PlayerView>();
            }
            break;

            default:
                throw new NotImplementedException("还没有这种类型的View");
            }
            view.Info = info;
            return(view);
        }
コード例 #5
0
        public CreatureOldLogic CreateLogic(CreatureInfo info)
        {
            CreatureOldLogic logic;

            switch (info.type)
            {
            case CreaturesType.Monsters:
                logic = new MonsterLogic(info);
                return(logic);

            case CreaturesType.Player:
                logic = new PlayerLogic(info);
                return(logic);

            default:
                throw new NotImplementedException("还没有这种类型的Logic");
            }
        }
コード例 #6
0
        private CreatureView CreateView(CreatureInfo info)
        {
            var view = factory.CreateView(info);

            return(view);
        }
コード例 #7
0
 public PlayerLogic(CreatureInfo info) : base(info)
 {
 }