예제 #1
0
        public override bool OnEvent(IEvent e)
        {
            if (e.GetType() == typeof(PlayerUnitSummonEvent))
            {
                PlayerUnitSummonEvent summonEvent = e as PlayerUnitSummonEvent;
                for (int i = -1; i < 2; i++)
                {
                    for (int j = -1; j < 2; j++)
                    {
                        if (i == 0 && j == 0)
                        {
                            continue;
                        }

                        if (summonEvent.SummonTilePos == Target.UnitPosition + new Vector3(i, 0, j))
                        {
                            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);
                        }
                    }
                }
            }
            return(false);
        }
예제 #2
0
        public override bool OnEvent(IEvent e)
        {
            if (e.GetType() == typeof(PlayerUnitSummonEvent))
            {
                PlayerUnitSummonEvent summonEvent  = e as PlayerUnitSummonEvent;
                PlayerUnit            playertarget = Target as PlayerUnit;
                for (int i = -1; i < 2; i++)
                {
                    for (int j = -1; j < 2; j++)
                    {
                        if (i == 0 && j == 0)
                        {
                            continue;
                        }

                        if (summonEvent.SummonTilePos == Target.UnitPosition + new Vector3(i, 0, j))
                        {
                            GameManager.Instance.EffectSystem.CreateEffect("BeamUpGreen", 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);
                            int hp = playertarget.MaxHP;
                            playertarget.SetMaxHP(hp + (int)(hp * 0.05));
                            playertarget.SetHP(playertarget.HP + (int)(hp * 0.05));
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
예제 #3
0
        // 필수 init 처리
        protected void SetEssentialInit(Vector3Int pos, List <Buff> buff, int hp, int damage, float attack_delay, string name)
        {
            // 버프 적용
            for (int i = 0; i < buff.Count; i++)
            {
                Buff buffCopy = buff[i].Copy();
                buffCopy.Init(this);
                buffList.Add(buffCopy);
            }

            // 상태 초기화
            currentState = PlayerUnitState.Init;

            // 값 초기화
            MaxHP              = hp;
            HP                 = hp;
            Damage             = damage;
            AttackDelay        = attack_delay;
            AdditionalDamage   = 0;
            DamageMultiplier   = 1;
            unitName           = name;
            CurrentAttackDelay = 0;

            // 유닛 위치 초기화
            this.gameObject.transform.position = pos + new Vector3(0, 0, -0.4f);
            UnitPosition = pos;

            // 업데이트 추가
            GameManager.Instance.AddUpdate(this);

            GameManager.Instance.MessageSystem.Publish(PlayerUnitSummonEvent.Create(pos, this));
        }
예제 #4
0
        // 구독한 이벤트 처리
        public sealed override bool OnEvent(IEvent e)
        {
            if (e.GetType() == typeof(DamageEvent))
            {
                DamageEvent DamageEvent = e as DamageEvent;
                if (DamageEvent.Target == (Unit)this)
                {
                    GameManager.Instance.EffectSystem.CreateEffect("SwordImpactRed", this.gameObject.transform.position + new Vector3(-0.1f, 0.4f, 0), new Vector3(0.4f, 0.4f, 0.4f), Quaternion.Euler(new Vector3(-90, 0, 0)), 2);
                    DamageEvent newDamageEvent = DamageEvent.Create(DamageEvent.Publisher, DamageEvent.Target, DamageEvent.Damage);

                    HP -= newDamageEvent.Damage;
                    if (HP <= 0)
                    {
                        currentState = MonsterUnitState.Dead;
                    }
                }
            }
            else if (e.GetType() == typeof(PlayerUnitSummonEvent))
            {
                PlayerUnitSummonEvent summonEvent = e as PlayerUnitSummonEvent;
                if (currentState == MonsterUnitState.Walk)
                {
                    for (int i = 0; i < rangeTile.Count; i++)
                    {
                        if (summonEvent.SummonTilePos == UnitPosition + rangeTile[i])
                        {
                            Target       = summonEvent.SummonUnit;
                            currentState = MonsterUnitState.Attack;
                        }
                    }
                }
            }
            return(false);
        }
예제 #5
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);
        }
예제 #6
0
        public static PlayerUnitSummonEvent Create(Vector3Int tilePos, PlayerUnit unit)
        {
            PlayerUnitSummonEvent e = new PlayerUnitSummonEvent();

            e.SummonTilePos = tilePos;
            e.SummonUnit    = unit;
            return(e);
        }