Beispiel #1
0
 internal virtual void Distribute(CPMessage cpMessage)
 {
     foreach (ComponentsParts CP in components)
     {
         CP.Recieve(cpMessage);
     }
 }
 internal override void Recieve(CPMessage message)
 {
     if (message.type == CPMessageType.TARGET)
     {
         Position_Target_X = message.x_position;
         Position_Target_Y = message.y_position;
     }
 }
Beispiel #3
0
        internal override void Recieve(CPMessage message)
        {
            Creature target = null;

            if (message.type == CPMessageType.MELEE_ATTACK)
            {
                foreach (Creature creature in owner.manager.creatures)
                {
                    if (creature.X_pos == message.x_position && creature.Y_pos == message.y_position && creature != owner)
                    {
                        target = creature;
                    }
                }

                if (target != null)
                {
                    Dictionary <string, Attack> availableAttacks = owner.body.GetAllAvailableAttacks();

                    if (availableAttacks.Count > 0)
                    {
                        int    random_attack_index = rnd.Next(availableAttacks.Count);
                        Attack attack = availableAttacks.ElementAt(random_attack_index).Value;

                        target.Distribute(new CPMessage()
                        {
                            type = CPMessageType.DAMAGE, attack = attack
                        });
                    }
                }
            }

            if (message.type == CPMessageType.RANGED_ATTACK)
            {
                foreach (Creature creature in owner.manager.creatures)
                {
                    if (creature.X_pos == message.x_position && creature.Y_pos == message.y_position && creature != owner)
                    {
                        target = creature;
                    }
                }

                if (target != null)
                {
                    List <Attack> availableRangedAttacks = owner.Inventory.GetRangedAttacks();
                    int           random_attack_index    = rnd.Next(availableRangedAttacks.Count);
                    Attack        attack = availableRangedAttacks.ElementAt(random_attack_index);

                    target.Distribute(new CPMessage()
                    {
                        type = CPMessageType.DAMAGE, attack = attack
                    });
                }
            }
        }
Beispiel #4
0
        internal void ApplyEffect(CPMessage message)
        {
            BodyPart damaged_bodyPart = owner.body.bodyparts.ElementAt(rnd.Next(owner.body.bodyparts.Count)).Value;

            if (damaged_bodyPart != null)
            {
                damaged_bodyPart.hitPoints -= message.attack.attack_damage;
                damaged_bodyPart.status    += 1;
                Console.WriteLine(owner.Name + " : " + damaged_bodyPart.name + "(" + message.attack.name + ")" +
                                  message.attack.attack_damage + "=" +
                                  (BodyPartStatus)damaged_bodyPart.status);
                if ((int)damaged_bodyPart.status > 5)
                {
                    owner.body.bodyparts.Remove(damaged_bodyPart.name);
                }
            }
        }
Beispiel #5
0
        internal override void Recieve(CPMessage message)
        {
            if (message.type == CPMessageType.DAMAGE)
            {
                if (owner.body.bodyparts.Count < 1)
                {
                    return;
                }

                ApplyEffect(message);

                if (message.attack.effect != EffectTypes.NONE)
                {
                    switch (message.attack.effect)
                    {
                    case EffectTypes.ZombieEffect:
                    {
                        if (!HasEffect(EffectTypes.ZombieEffect))
                        {
                            ZombieEffect effect = new ZombieEffect
                            {
                                owner = owner
                            };


                            owner.effects.Add(effect);
                            break;
                        }
                        else
                        {
                            break;
                        }
                    }

                    case EffectTypes.BLAST:
                    {
                        owner.glyph = 'A';
                        break;
                    }
                    }
                }
            }
        }
 internal override void Recieve(CPMessage message)
 {
 }