Ejemplo n.º 1
0
        public bool OnEvent(IEvent e)
        {
            Type eventType = e.GetType();

            // 자기 타일에 몬스터가 들어오거나 나갈 때 리스트에서 제거
            if (eventType == typeof(TileEnterEvent))
            {
                TileEnterEvent enterEvent = e as TileEnterEvent;
                if (enterEvent.EnterTilePos.x == tileTransform.position.x && enterEvent.EnterTilePos.z == tileTransform.position.z)
                {
                    containMonsterUnitList.Add((MonsterUnit)enterEvent.EnterUnit);

                    //Debug.Log(tileTransform.position + " 몬스터 IN " + containMonsterUnitList.Count);
                }
                return(true);
            }
            else if (eventType == typeof(TileLeaveEvent))
            {
                TileLeaveEvent leaveEvent = e as TileLeaveEvent;
                if (leaveEvent.LeaveTilePos.x == tileTransform.position.x && leaveEvent.LeaveTilePos.z == tileTransform.position.z)
                {
                    containMonsterUnitList.Remove((MonsterUnit)leaveEvent.LeaveUnit);

                    //Debug.Log(tileTransform.position + " 몬스터 OUT " + containMonsterUnitList.Count);
                }
                return(true);
            }
            else if (eventType == typeof(MonsterDeadEvent))
            {
                MonsterDeadEvent deadEvent = e as MonsterDeadEvent;
                if (deadEvent.DeadPos.x == tileTransform.position.x && deadEvent.DeadPos.z == tileTransform.position.z)
                {
                    containMonsterUnitList.Remove(deadEvent.DeadUnit);
                    //Debug.Log(tileTransform.position + " 몬스터 Dead " + containMonsterUnitList.Count);
                }
                return(true);
            }
            else if (eventType == typeof(PlayerUnitSummonEvent))
            {
                PlayerUnitSummonEvent summonEvent = e as PlayerUnitSummonEvent;
                if (summonEvent.SummonTilePos.x == tileTransform.position.x && summonEvent.SummonTilePos.z == tileTransform.position.z)
                {
                    containPlayerUnit = summonEvent.SummonUnit;
                    //Debug.Log(tileTransform.position + " 유닛 Summon " + containPlayerUnit);
                }
                return(true);
            }
            else if (eventType == typeof(PlayerUnitDeadEvent))
            {
                PlayerUnitDeadEvent deadEvent = e as PlayerUnitDeadEvent;
                if (deadEvent.DeadPos.x == tileTransform.position.x && deadEvent.DeadPos.z == tileTransform.position.z)
                {
                    containPlayerUnit = null;
                    //Debug.Log(tileTransform.position + " 유닛 Dead " + containPlayerUnit);
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public static TileEnterEvent Create(Vector3Int tilePos, Unit unit)
        {
            TileEnterEvent e = new TileEnterEvent();

            e.EnterTilePos = tilePos;
            e.EnterUnit    = unit;

            return(e);
        }
Ejemplo n.º 3
0
        public override bool OnEvent(IEvent e)
        {
            if (e.GetType() == typeof(TileEnterEvent))
            {
                TileEnterEvent tileEnter = e as TileEnterEvent;

                PlayerUnit playertarget = Target as PlayerUnit;
                if (TileManager.Instance.GetContainPlayerUnit(tileEnter.EnterTilePos.x, tileEnter.EnterTilePos.z) == playertarget)
                {
                    GameManager.Instance.EffectSystem.CreateEffect("BeamUpRed", Target.UnitPosition + new Vector3(0, 0.2f, -0.2f),
                                                                   new Vector3(0.3f, 0.3f, 0.3f), Quaternion.Euler(new Vector3(-90, 0, 0)), 1);
                    Target.AddAdditionalDamage(10);
                }
            }
            return(true);
        }
Ejemplo n.º 4
0
        public sealed override bool OnEvent(IEvent e)
        {
            if (e.GetType() == typeof(TileEnterEvent))
            {
                TileEnterEvent enterEvent = e as TileEnterEvent;
                if (currentState == PlayerUnitState.Idle)
                {
                    foreach (var rangeTilePos in rangeTile)
                    {
                        if (rangeTilePos == enterEvent.EnterTilePos)
                        {
                            currentState = PlayerUnitState.Attack;
                            Target       = (MonsterUnit)enterEvent.EnterUnit;
                            return(true);
                        }
                    }
                }
            }
            else if (e.GetType() == typeof(DamageEvent))
            {
                DamageEvent DamageEvent = e as DamageEvent;
                if (DamageEvent.Target == (Unit)this)
                {
                    DamageEvent newDamageEvent = DamageEvent.Create(DamageEvent.Publisher, DamageEvent.Target, DamageEvent.Damage);

                    if (HP > newDamageEvent.Damage)
                    {
                        HP -= newDamageEvent.Damage;
                    }
                    else
                    {
                        HP           = 0;
                        currentState = PlayerUnitState.Dead;
                    }
                }
            }
            else if (e.GetType() == typeof(BattleStageEndEvent))
            {
                Dispose(true);
            }
            return(false);
        }
Ejemplo n.º 5
0
 protected void Walk(float dt)
 {
     monsterTransform.position = Vector3.MoveTowards(monsterTransform.position, pathList[0], dt * speed);
     // 거리가 특정 거리 이하 일때 발생
     if (Vector3.Distance(monsterTransform.position, pathList[0]) <= 0.1)
     {
         currentState = MonsterUnitState.SetPath;
     }
     else if (Vector3.Distance(monsterTransform.position, pathList[0]) <= 0.5 && pathList[0] != UnitPosition)
     {
         // 절반정도 진입했으면 TileEnter, TileLeave발행하고 포함된 타일 변경 + 적이 있는지 체크
         GameManager.Instance.MessageSystem.Publish(TileLeaveEvent.Create(UnitPosition, this));
         UnitPosition = pathList[0];
         GameManager.Instance.MessageSystem.Publish(TileEnterEvent.Create(UnitPosition, this));
         if (CheckPlayerUnit())
         {
             currentState = MonsterUnitState.Attack;
         }
     }
 }
Ejemplo n.º 6
0
        public override bool OnEvent(IEvent e)
        {
            if (e.GetType() == typeof(TileEnterEvent))
            {
                TileEnterEvent tileEnter = e as TileEnterEvent;

                PlayerUnit playertarget = Target as PlayerUnit;
                if (TileManager.Instance.GetContainPlayerUnit(tileEnter.EnterTilePos.x, tileEnter.EnterTilePos.z) == playertarget)
                {
                    GameManager.Instance.EffectSystem.CreateEffect("HealExplosionGreen", Target.UnitPosition + new Vector3(0, 0.4f, -0.1f), new Vector3(0.5f, 0.5f, 0.5f), Quaternion.Euler(new Vector3(-90, 0, 0)), 1);
                    int hp = playertarget.HP;
                    if (hp + (int)(hp * 0.1) < playertarget.MaxHP)
                    {
                        playertarget.SetHP(hp + (int)(hp * 0.1));
                    }
                    else
                    {
                        playertarget.SetHP(playertarget.MaxHP);
                    }
                }
            }
            return(true);
        }