Пример #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);
        }
Пример #2
0
        public static PlayerUnitDeadEvent Create(Vector3Int deadPos, PlayerUnit unit)
        {
            PlayerUnitDeadEvent e = new PlayerUnitDeadEvent();

            e.DeadPos  = deadPos;
            e.DeadUnit = unit;

            return(e);
        }
Пример #3
0
        public override bool OnEvent(IEvent e)
        {
            if (e.GetType() == typeof(PlayerUnitDeadEvent))
            {
                PlayerUnitDeadEvent deadEvent = e as PlayerUnitDeadEvent;

                PlayerUnit playertarget = Target as PlayerUnit;
                if (deadEvent.DeadUnit != 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);
        }
Пример #4
0
        public sealed override IEnumerator Dead()
        {
            Dispose(false);

            GameManager.Instance.MessageSystem.Publish(PlayerUnitDeadEvent.Create(UnitPosition, this));
            UnitAnimator.SetBool("dead", true);
            yield return(new WaitForSeconds(1f));

            float alpha = gameObject.transform.GetComponent <SpriteRenderer>().material.color.a;

            for (float t = 0.0f; t < 1.0f; t += Time.deltaTime / 1)
            {
                Color newColor = new Color(1, 1, 1, Mathf.Lerp(alpha, 0, t));
                transform.GetComponent <SpriteRenderer>().material.color = newColor;
                yield return(null);
            }
            UnitAnimator.SetBool("dead", false);
            FieldObjectManager.Instance.ReleaseUnit(unitName, this);
        }