NormalAttack() public static method

public static NormalAttack ( int Index_ ) : void
Index_ int
return void
示例#1
0
        public static void AttackTimer_Elapsed(object sender, EventArgs e)
        {
            Timer objB  = (Timer)sender;
            int   Index = -1;

            for (int i = Information.LBound(PlayerAttack, 1); i <= Information.UBound(PlayerAttack, 1); i++)
            {
                if (object.ReferenceEquals(PlayerAttack[i], objB))
                {
                    Index = i;
                    break;
                }
            }
            if (Index > -1)
            {
                if (Player.Objects[Index].NormalAttack)
                {
                    Player.General[Index].Busy = false;
                    Attack.NormalAttack(Index);
                }
                if (Player.Objects[Index].UsingSkill)
                {
                    Player.Objects[Index].UsingSkill = false;
                    Player.General[Index].Busy       = false;
                    PlayerAttack[Index].Stop();
                }
            }
        }
示例#2
0
        public static void Action(PacketReader reader_, int Index_)
        {
            PacketWriter writer = new PacketWriter();

            reader_.ModifyIndex(1);
            byte type = reader_.ReadByte();

            if (Player.General[Index_].State != 1)
            {
                switch (type)
                {
                case 1:

                    reader_.ModifyIndex(1);
                    uint ObjectId = reader_.ReadDword();
                    Player.Objects[Index_].AttackingObjectId = ObjectId;
                    int ObjectIndex = Players.GetObjectIndexAndType(Index_, Player.Objects[Index_].AttackingObjectId);

                    bool attack = false;

                    if (Player.Objects[Index_].SelectedObjectType == 2)
                    {
                        attack = Movement.MoveToObject(Index_, ref Player.Position[Index_], Monsters.Position[ObjectIndex], Player.General[Index_], false);
                    }

                    else
                    {
                        attack = Movement.MoveToObject(Index_, ref Player.Position[Index_], Player.Position[ObjectIndex], Player.General[Index_], false);
                    }

                    if (attack)
                    {
                        if (!Player.Objects[Index_].NormalAttack)
                        {
                            Attack.NormalAttack(Index_);
                        }
                    }
                    break;

                case 2:
                    reader_.ModifyIndex(1);
                    ObjectId = reader_.ReadDword();

                    ObjectIndex = 0;
                    for (int i = 0; i <= Item.ItemAmount; i++)
                    {
                        if (Item.General[i].UniqueID == ObjectId && Index_ != i)
                        {
                            ObjectIndex = i;
                            break;
                        }
                    }

                    bool pickup = false;

                    pickup = Movement.MoveToObject(Index_, ref Player.Position[Index_], Item.Position[ObjectIndex], Player.General[Index_], false);

                    if (pickup)
                    {
                        PickUpItem(Index_, ObjectIndex);
                    }

                    break;

                case 4:

                    uint skillid = reader_.ReadDword();

                    bool skillexist          = false;
                    int  CharacterSkillIndex = DatabaseCore.Skill.GetIndexByName(Player.General[Index_].CharacterName);

                    for (int i = 0; i <= DatabaseCore.Skill.SkillAmount[CharacterSkillIndex]; i++)
                    {
                        if (skillid == DatabaseCore.Skill.Skills[CharacterSkillIndex].SkillId[i])
                        {
                            skillexist = true;
                            break;
                        }
                        skillexist = false;
                    }

                    if (skillexist)
                    {
                        byte type_ = reader_.ReadByte();
                        switch (type_)
                        {
                        case 0:
                            bool alreadyactive = false;
                            for (byte i = 0; i < Player.Objects[Index_].ActiveBuffs.Length; i++)
                            {
                                if (Player.Objects[Index_].ActiveBuffs[i].Id == skillid)
                                {
                                    alreadyactive = true;
                                }
                            }
                            if (!alreadyactive)
                            {
                                Player.Objects[Index_].UsingSkillID = skillid;
                                if (!Player.Objects[Index_].UsingSkill)
                                {
                                    PrepareBuff(Index_);
                                }
                            }
                            return;

                        case 1:
                            uint attackingObjectId = reader_.ReadDword();

                            Player.Objects[Index_].AttackingSkillID  = skillid;
                            Player.Objects[Index_].AttackingObjectId = attackingObjectId;
                            Player.Objects[Index_].NormalAttack      = false;
                            if (!Player.Objects[Index_].UsingSkill)
                            {
                                SkillAttackType(Index_);
                            }

                            return;
                        }
                    }
                    break;

                default:
                    Timers.PlayerAttack[Index_].Stop();
                    break;
                }
            }
        }