コード例 #1
0
        private void OnAnimationEventTriggered(tk2dSpriteAnimator animator, tk2dSpriteAnimationClip clip, int frameIndex)
        {
            CameraUtils.Shake();

            IList <MonsterEntity2D> monsters = DungeonManager.GetInstance().monsters;

            for (int index = monsters.Count - 1; index >= 0; index--)
            {
                MonsterEntity2D mosnter = monsters[index];

                if (mosnter.motor2D.isGrounded)
                {
                    mosnter.OnSkillHit(owner, data, owner.transform.position);

                    if (mosnter.machine.currentState.GetName() == StateTypes.Dead.ToString())
                    {
                        ComponentDefaultEffect componentEffect = mosnter.gameObject.AddComponent <ComponentDefaultEffect>();
                        componentEffect.spinEnabled = false;
                        componentEffect.minForce    = 0.5f;
                        componentEffect.maxForce    = 1.0f;
                        componentEffect.gravity     = -6.0f;
                        componentEffect.minSpeed    = 0.4f;
                        componentEffect.maxSpeed    = 0.6f;
                    }
                }
            }
        }
コード例 #2
0
        void Start()
        {
            SoundManager.GetInstance().PlayOneShot(AudioRepository.LoadExplosionAudio(missile.audioID));

            animator.AnimationCompleted = delegate(tk2dSpriteAnimator sprite, tk2dSpriteAnimationClip clip)
            {
                animator.AnimationCompleted = null;

                missile = null;

                Destroy(gameObject);
            };

            if (missile.WOE != 0)
            {
                Collider2D[] hits = Physics2D.OverlapCircleAll(this.transform.position, this.missile.WOE);

                IList <GameObject> hitedCache = new List <GameObject>();
                foreach (Collider2D hit in hits)
                {
                    MonsterEntity2D entity = hit.gameObject.GetComponent <MonsterEntity2D>();

                    if (entity != null && !hitedCache.Contains(entity.gameObject))
                    {
                        entity.OnMissileHit(sender, missile, this.transform.position);

                        hitedCache.Add(hit.gameObject);
                    }
                }

                hitedCache.Clear();
            }
        }
コード例 #3
0
        protected override void Activate()
        {
            base.Activate();

            if (owner.motor2D.isGrounded)
            {
                MonsterEntity2D monster = owner as MonsterEntity2D;

                state            = new DashState();
                state.isDashing  = true;
                state.dashDir    = -monster.direction;
                state.start      = monster.transform.position;
                state.timeDashed = Time.deltaTime;

                monster.machine.ChangeState(StateTypes.BackDash.ToString());

                Transform mountPoint = monster.GetMountPoint(ComponentDefs.Foot);

                if (mountPoint != null)
                {
                    effector = ResourceUtils.GetComponent <tk2dSpriteAnimator>(GlobalDefinitions.RESOURCE_PATH_BUFF + data.resourceID);
                    effector.transform.SetParent(mountPoint);
                    effector.transform.localPosition = Vector3.zero;
                    effector.AnimationCompleted      = (tk2dSpriteAnimator animator, tk2dSpriteAnimationClip clip) =>
                    {
                        GameObject.Destroy(effector.gameObject);
                    };
                }
            }
        }
コード例 #4
0
        protected override void Activate()
        {
            base.Activate();

            MonsterEntity2D monster = owner as MonsterEntity2D;

            monster.machine.ChangeState(StateTypes.Dizzy.ToString());

            Transform mountPoint = owner.GetMountPoint(ComponentDefs.Head);

            if (mountPoint != null)
            {
                effector = ResourceUtils.GetComponent <Transform>(GlobalDefinitions.RESOURCE_PATH_BUFF + data.resourceID);
                effector.SetParent(mountPoint);
                effector.localPosition = Vector3.zero;
            }
        }
コード例 #5
0
        private void OnDungeonMonsterTransfer(object data)
        {
            MonsterEntity2D entity = data as MonsterEntity2D;

            if (monsters.Contains(entity))
            {
                Vector3 thePosition = entity.transform.position;
                thePosition.x = mapWrapper.monsterOutPoint.Value.x;
                thePosition.y = mapWrapper.monsterOutPoint.Value.y;

                entity.transform.position = thePosition;

                entity.machine.ChangeState(StateTypes.Idle.ToString());

                entity.FadeIn();
            }
        }
コード例 #6
0
        protected override void Deactivate()
        {
            base.Deactivate();

            MonsterEntity2D monster = owner as MonsterEntity2D;

            if (monster.data.attributeBox.GetAttribute(Prototype.AttributeKeys.HP) > 0)
            {
                monster.machine.ChangeState(StateTypes.Wander.ToString());
            }

            if (effector != null)
            {
                Destroy(effector.gameObject);
            }

            Destroy(this);
        }
コード例 #7
0
        private MonsterEntity2D CreateMonsterEntity(SpwanPointIds pointID, MonsterData monsterData)
        {
            SpwanPoint2D point = null;

            if (monsterData.isBoss)
            {
                point = mapWrapper.bossSpawnPoints[UnityEngine.Random.Range(0, mapWrapper.bossSpawnPoints.Count)];
            }
            else
            {
                IList <SpwanPoint2D> points = null;

                mapWrapper.monsterSpawnPoints.TryGetValue(pointID, out points);

                if (points.Count != 0)
                {
                    point = points[UnityEngine.Random.Range(0, points.Count)];
                }
            }

            if (point == null)
            {
                return(null);
            }

            MonsterEntity2D entity = ResourceUtils.GetComponent <MonsterEntity2D>(GlobalDefinitions.RESOURCE_PATH_MONSTER + monsterData.resourceID);

            entity.BindData(monsterData);
            entity.OnDispose = () => { monsters.Remove(entity); };

            LayerManager.GetInstance().AddObject(entity.transform);
            monsters.Add(entity);

            entity.transform.position += point.transform.position;
            entity.direction           = point.direction;

            if (point.direction == Vector2.right)
            {
                entity.Flip();
            }

            return(entity);
        }
コード例 #8
0
        protected void OnCollisionEnter2D(Collision2D coll)
        {
            #region Hit Monster
            if (coll.gameObject.layer == LayerMaskDefines.MONSTER.id)
            {
                MonsterEntity2D entity = coll.gameObject.GetComponent <MonsterEntity2D>();

                if (entity.machine.currentState.GetName() != StateTypes.Dead.ToString())
                {
                    if (data.WOE == 0)
                    {
                        entity.OnMissileHit(owner, data, coll.contacts[0].point);
                    }

                    ProcessCollision(coll.contacts[0].point);

                    ProcessPhsysicsType(coll.gameObject, data.physicsType);
                }
                else
                {
                    body2D.velocity = velocity;

                    Collider2D[] colliders = coll.gameObject.GetComponents <Collider2D>();

                    for (int index = 0; index < colliders.Length; index++)
                    {
                        Physics2D.IgnoreCollision(GetComponent <Collider2D>(), colliders[index]);
                    }
                }
            }
            #endregion

            #region Hit Missile
            if (coll.gameObject.layer == LayerMaskDefines.MONSTER_MISSILE.id)
            {
                ProcessPhsysicsType(coll.gameObject, data.physicsType);
            }
            #endregion
        }
コード例 #9
0
        private void OnDungeonMonsterDamage(object data)
        {
            object[] datas = data as object[];

            MonsterEntity2D entity  = datas[0] as MonsterEntity2D;
            ValidatePayload payload = datas[1] as ValidatePayload;

            DamagePopUpUI view = LayerManager.GetInstance().AddPopUpView <DamagePopUpUI>();

            view.Initialize(payload);

            view.transform.position = entity.GetMountPoint(ComponentDefs.HUD).transform.position;

            float currentHP = entity.data.attributeBox.GetAttribute(AttributeKeys.HP);
            float maxHP     = entity.data.attributeBox.GetAttribute(AttributeKeys.MaxHP);
            float percent   = currentHP / maxHP;

            entity.UpdateHUD();

            entity.componentsHolder.ValidateAndUpdate(percent);

            foreach (EntityComponent component in entity.componentsHolder.components)
            {
                component.Blink();
            }

            if (entity.data.attributeBox.GetAttribute(AttributeKeys.HP) <= 0)
            {
                EventBox.Send(CustomEvent.TROPHY_UPDATE, new KeyValuePair <TrophyType, float>(TrophyType.DungeonKillMonster, 1));

                entity.machine.ChangeState(StateTypes.Dead.ToString(), payload);

                float value = entity.data.attributeBox.GetAttribute(AttributeKeys.RP);

                if (value != 0)
                {
                    UserManager.GetInstance().AddRP(value);
                }

                value = entity.data.attributeBox.GetAttribute(AttributeKeys.GP);

                if (value != 0)
                {
                    UserManager.GetInstance().AddGP(value);
                }

                if (monsters.Contains(entity))
                {
                    monsters.Remove(entity);
                }

                if (entity is BossEntity2D)
                {
                    EndBattle(BattleResult.Win);
                }
                else
                {
                    if (monsters.Count == 0)
                    {
                        if (dungeon.currentGroup != null && dungeon.currentGroup.HasMonsters())
                        {
                            CreateAllMonsterGroup();
                        }
                        else
                        {
                            CheckBattleResult();
                        }
                    }
                }
            }
        }