コード例 #1
0
ファイル: CombatContext.cs プロジェクト: lyndev/EGamePlay
        public void RefreshActions()
        {
            foreach (var item in TurnActions)
            {
                Entity.Destroy(item);
            }
            TurnActions.Clear();

            foreach (var item in HeroEntities)
            {
                var turnAction = item.Value.CreateAction <TurnAction>();
                if (MonsterEntities.ContainsKey(item.Key))
                {
                    turnAction.Target = MonsterEntities[item.Key];
                }
                else
                {
                    turnAction.Target = MonsterEntities.Values.ToArray().First();
                }
                TurnActions.Add(turnAction);
            }
            foreach (var item in MonsterEntities)
            {
                var turnAction = item.Value.CreateAction <TurnAction>();
                if (HeroEntities.ContainsKey(item.Key))
                {
                    turnAction.Target = HeroEntities[item.Key];
                }
                else
                {
                    turnAction.Target = HeroEntities.Values.ToArray().First();
                }
                TurnActions.Add(turnAction);
            }
        }
コード例 #2
0
        public static ActorEntity GetMonsterEntity(UInt32 key)
        {
            ActorEntity monster;

            MonsterEntities.TryGetValue(key, out monster);
            return(monster);
        }
コード例 #3
0
        public CombatEntity AddMonsterEntity(int seat)
        {
            var entity = AddChild <CombatEntity>();

            entity.IsHero = false;
            MonsterEntities.Add(seat, entity);
            entity.SeatNumber = seat;
            return(entity);
        }
コード例 #4
0
 public void OnCombatEntityDead(CombatEntity combatEntity)
 {
     if (combatEntity.IsHero)
     {
         HeroEntities.Remove(combatEntity.SeatNumber);
     }
     else
     {
         MonsterEntities.Remove(combatEntity.SeatNumber);
     }
 }
コード例 #5
0
        public async void StartCombat()
        {
            RefreshActions();
            foreach (var item in TurnActions)
            {
                if (item.Creator.CheckDead() || item.Target.CheckDead())
                {
                    continue;
                }
                await item.ApplyTurn();
            }
            await TimerComponent.Instance.WaitAsync(1000);

            if (HeroEntities.Count == 0 || MonsterEntities.Count == 0)
            {
                HeroEntities.Clear();
                MonsterEntities.Clear();
                await TimerComponent.Instance.WaitAsync(2000);

                this.Publish(new CombatEndEvent());
                return;
            }
            StartCombat();
        }
コード例 #6
0
        public static bool RemoveMonsterEntity(UInt32 key)
        {
            ActorEntity removed;

            return(MonsterEntities.TryRemove(key, out removed));
        }
コード例 #7
0
 public static void EnsureMonsterEntity(UInt32 key, ActorEntity entity)
 {
     MonsterEntities.AddOrUpdate(key, entity, (k, v) => entity);
 }