Example #1
0
        private void _createEnemyPartyMember(object[] args)
        { // createEnemyPartyMember(string actorPartyMemberSelector, string partyMemberName, int relativeLayoutIndex, bool addParticleEffect)
            string actorPartyMemberSelector = (string)args[0];
            string partyMemberName          = (string)args[1];
            int    relativeLayoutIndex      = (int)args[2];
            bool   addParticleEffect        = (bool)args[3];

            PartyMember actor = getPartyMemberFromSelector(actorPartyMemberSelector);

            PartyMember partyMember = ResourceManager.GetNewPartyMember(partyMemberName);

            battle.EnemyParty.AddPartyMember(partyMember);
            partyMember.StartBattle();
            partyMember.EquipDefaultWeapon(battle.EnemyParty);
            battle.AddBattleEntity(partyMember.BattleEntity);

            List <PartyMember> actorList = battle.EnemyPartyLayout.GetListWithPartyMember(actor);
            List <PartyMember> newList   = battle.EnemyPartyLayout.RelativeList(actorList, relativeLayoutIndex);

            newList.Add(partyMember);

            battle.RepositionPartyMembers();

            if (addParticleEffect)
            {
                ParticleEffect particleEffect = ParticleEffect.AddSmokePuff(partyMember.BattleEntity.GetCenter(), battle);
                particleEffect.DepthOverride = partyMember.BattleEntity.Position.Y + 5.0f;
            }
        }
Example #2
0
        private void _createProjectile(object[] args)
        { // createProjectile(string actorPartyMemberSelector, string boneName, string spriteName, bool facingRight, float speed, Script callback, string targetPartyMemberSelector, bool addParticleEffect)
            string actorPartyMemberSelector = (string)args[0];
            string boneName    = (string)args[1];
            string spriteName  = (string)args[2];
            bool   facingRight = (bool)args[3];
            float  speed       = (float)args[4];
            Script callback    = (Script)args[5];
            string targetPartyMemberSelector = (string)args[6];
            bool   addParticleEffect         = (bool)args[7];

            PartyMember actor  = getPartyMemberFromSelector(actorPartyMemberSelector);
            PartyMember target = getPartyMemberFromSelector(targetPartyMemberSelector);

            Bone    bone     = actor.BattleEntity.Skeleton.FindBone(boneName);
            Vector2 position = new Vector2(bone.WorldX, bone.WorldY);

            Sprite sprite = ResourceManager.GetNewSprite(spriteName);

            blocked = true;
            ScriptRunner self = this;

            Scene.AddEntity(new Projectile(sprite, position, facingRight, actor, target, speed, projectile =>
            {
                projectile.Kill();
                self.addNestedScriptRunner(callback, 0.0f);
                if (addParticleEffect)
                {
                    ParticleEffect particleEffect = ParticleEffect.AddSmokePuff(projectile.Position, self.battle);
                    particleEffect.DepthOverride  = target.BattleEntity.Position.Y + 5.0f;
                }
                self.blocked = false;
            }));
        }
Example #3
0
        public void DoDamage(int amount, bool ignoreShield, bool playAnimation = true)
        {
            if (amount > 0 && !ignoreShield)
            {
                HurtThisTurn = true;
            }

            bool aliveBefore = Alive;
            bool heal        = amount < 0;

            if (heal)
            {
                int finalHealth = Health - amount;
                if (finalHealth > MaxHealth)
                {
                    amount = -(MaxHealth - Health);
                }
            }
            else if (amount > Health)
            {
                amount = Health;
            }
            Health -= amount;

            Battle battle = Scene.Current as Battle;

            if (Health <= 0)
            {
                Health = 0;
                if (aliveBefore)
                {
                    BattleEntity.Visible = false;
                    EquippedShield       = null;
                    EquippedWeapon       = null;
                    if (battle != null)
                    {
                        ParticleEffect.AddSmokePuff(BattleEntity.GetCenter(), battle);
                    }
                }
            }
            else if (Health > MaxHealth)
            {
                Health = MaxHealth;
            }

            if (battle != null)
            {
                if ((amount > 0 || (amount == 0 && !ignoreShield)) && playAnimation)
                {
                    BattleEntity.AnimationState.SetAnimation(GetBattleEntityHurtAnimationName(), false);
                    BattleEntity.AnimationState.AddAnimation(GetBattleEntityIdleAnimationName(), true);
                }
                Scene.AddEntity(new FloatingText(Math.Abs(amount).ToString(), heal ? Color.Blue : Color.Red, BattleEntity.GetCenter(), 5.0f, true));
            }
        }
Example #4
0
        public void Trigger(PartyMember partyMember, PartyBattleLayout partyBattleLayout)
        {
            int damage = partyMember.CalculateDamageTaken(this);

            if (damage > 0)
            {
                partyMember.DoDamage(damage, true, false);
            }
            if (partyMember.Alive)
            {
                partyMember.ApplyStatusEffectsFromAttributes(setter, Attributes, battle);
            }

            if (Attributes.Enhancement == Enhancement.Explosive)
            {
                ParticleEffect.AddExplosion(entity.GetCenter(), battle);
                List <PartyMember> partyMemberList = partyBattleLayout.GetListBehindTrap(this);
                if (partyMemberList != null && partyMemberList.Count > 0)
                {
                    PartyMember frontPartyMember = partyMemberList[0];
                    damage = frontPartyMember.CalculateDamageTaken(this);
                    frontPartyMember.DoDamage(damage, false);
                    if (frontPartyMember.Alive)
                    {
                        frontPartyMember.ApplyStatusEffectsFromAttributes(setter, Attributes, battle);
                    }
                }
            }
            else
            {
                ParticleEffect.AddSmokePuff(entity.GetCenter(), battle);
            }

            partyBattleLayout.RemoveTrap(this);
            Kill();
        }