Example #1
0
        protected virtual void ProcessCollision(Collider2D col, CollisionType type = CollisionType.Enter)
        {
            if (col.tag != "Terrain")            //Ignoring terrain collisions speeds up performance here
            {
                bool willBounce = false;
                if (type == CollisionType.Enter)
                {
                    if (slots.controller)
                    {
                        BounceState bounce = slots.controller.bounceState;
                        if (bounce && slots.collider)
                        {
                            if (bounce.CanBounce(slots.collider, col))
                            {
                                willBounce = true;
                                bounce.StartBounce(slots.collider, col);
                                RexActor bouncedOnActor = col.GetComponent <RexActor>();
                                if (bouncedOnActor)
                                {
                                    bouncedOnActor.Damage(bounce.damageDealt, false);
                                    bouncedOnActor.OnBouncedOn(slots.collider);
                                }
                            }
                        }
                    }
                }

                if (!willBounce)
                {
                    ContactDamage contactDamage = col.GetComponent <ContactDamage>();
                    if (contactDamage != null)
                    {
                        if (col.GetComponent <RexActor>() && col.GetComponent <RexActor>().isDead)
                        {
                            return;
                        }

                        if (tag == "Player" && contactDamage.willDamagePlayer)
                        {
                            Damage(contactDamage.amount, true, BattleEnums.DamageType.Regular, col);
                        }
                        else if (tag == "Enemy" && contactDamage.willDamageEnemies)
                        {
                            Damage(contactDamage.amount, true, BattleEnums.DamageType.Regular, col);
                        }
                    }
                }
            }
        }
        protected override void TriggerEffect(RexActor player)
        {
            if (player == null)
            {
                return;
            }

            if (energyType == EnergyType.HP)
            {
                if (equation == Equation.Increment)
                {
                    player.RestoreHP(amount);
                }
                else
                {
                    player.Damage(amount);
                }
            }
            else if (energyType == EnergyType.Weapon)
            {
                if (equation == Equation.Increment)
                {
                    player.RestoreMP(amount);
                }
                else
                {
                    player.DecrementMP(amount);
                }
            }
            else if (energyType == EnergyType.Lives)
            {
                if (equation == Equation.Increment)
                {
                    LivesManager.Instance.IncrementLives(amount);
                }
                else
                {
                    LivesManager.Instance.DecrementLives(amount);
                }
            }
        }