Пример #1
0
 public bool PutItem(SpawnItems s)
 {
     if (FindOpenSlot() <= -1)
         return false;
     Slot[FindOpenSlot()].Item = s;
     return true;
 }
        public void PickItems(SpawnItems item)
        {
            //if (_inventory.Count >= 8 + ExtraInventorySpace)
            //    return;

            int nullat = FindNextEmptySpace();
            if (nullat < 8 + ExtraInventorySpace)
            {
                _inventory[nullat] = item;
                Program.MyMap.Drop[Y + Program.MyMap.MinY][X + Program.MyMap.MinX].Remove(item);
                if (_playerParty > -1)
                    Program.Log.AddMessage((int)InGameLogMessageType.Event, Name + " picked a " + Program.Data.MyItems[item.ID].Name);
            }
        }
 public void EquipItems(SpawnItems s)
 {
     switch ((ItemType)Program.Data.MyItems[s.ID].Type)
     {
         case ItemType.Weapon:
             _equipment[11] = s;
             if (_playerParty > -1)
                 Program.Log.AddMessage((int)InGameLogMessageType.Event, Name + " equiped " + Program.Data.MyItems[_equipment[11].ID].Name);
             break;
     }
 }
Пример #4
0
        public override void Update()
        {
            if (ActionCooldown > 0)
                ActionCooldown--;

            if (LeftAttackCooldown > 0)
                LeftAttackCooldown--;

            if (RightAttackCooldown > 0)
                RightAttackCooldown--;

            switch (CurrentAction)
            {
                case 2:
                    if (ActionCooldown == 0)
                    {
                        ConstructionGUI g = (ConstructionGUI)Program.SM.States[1].GameGUI[9];
                        if (g.Visibility)
                        {
                            if (CurMap.SpawnedSpawnableLocation[g.LocY][g.LocX] > -1)
                            {
                                SpawnBuildable b = (SpawnBuildable)CurMap.SpawnedSpawnable[CurMap.SpawnedSpawnableLocation[g.LocY][g.LocX]];
                                for (int ibr = 0; ibr < b.Required.Count; ibr++)
                                {
                                    if (b.Required.ElementAt(ibr).Value.Count > 0)
                                    {
                                        SpawnItems consitem = b.Required.ElementAt(ibr).Value[0];
                                        b.Required.ElementAt(ibr).Value.RemoveAt(0);
                                        b.Built.ElementAt(ibr).Value.Add(consitem);
                                        ActionCooldown = 60;
                                    }
                                }
                                bool constructhadallitem = true;
                                for (int cihbe = 0; cihbe < b.Required.Count; cihbe++)
                                {
                                    if (b.Built.ElementAt(cihbe).Value.Count < Program.Data.GetBuildableList()[b.ID].RequiredItems.ElementAt(cihbe).Value)
                                        constructhadallitem = false;
                                }
                                if (constructhadallitem)
                                {

                                    CurrentAction = 0;
                                    b.FinishBuilding();
                                    g.Visibility = false;
                                }
                            }
                        }
                    }
                    break;
                case 3:
                    if (ActionCooldown == 0)
                    {
                        //Logic.RemoveItemsFromInventory(Logic.CurrentParty.MainParty.MyParty[0], i.ItemRequired.ElementAt(r).Key, i.ItemRequired.ElementAt(r).Value);
                        CraftGUI g = (CraftGUI)Program.SM.States[1].GameGUI[10];
                        for (int r = 0; r < Program.Data.MyItems[Logic.KnownRecipeForThisCharacter(Logic.CurrentParty.MainParty.MyParty[0], g.CurClass)[g.CurPick + 4 * g.PickPage]].ItemRequired.Count; r++)
                        {
                            Logic.RemoveItemsFromInventory(Logic.CurrentParty.MainParty.MyParty[0], Program.Data.MyItems[Logic.KnownRecipeForThisCharacter(Logic.CurrentParty.MainParty.MyParty[0], g.CurClass)[g.CurPick + 4 * g.PickPage]].ItemRequired.ElementAt(r).Key, Program.Data.MyItems[Logic.KnownRecipeForThisCharacter(Logic.CurrentParty.MainParty.MyParty[0], g.CurClass)[g.CurPick + 4 * g.PickPage]].ItemRequired.ElementAt(r).Value);
                        }
                        CurrentAction = 0;
                        //Logic.CurrentParty.MainParty.MyParty[0].Inventory[Logic.CurrentParty.MainParty.MyParty[0].FindNextEmptySpace()] = new SpawnItems(Logic.KnownRecipeForThisCharacter(Logic.CurrentParty.MainParty.MyParty[0], g.CurClass)[g.CurPick + 4 * g.PickPage]);
                        Inventory[FindNextEmptySpace()] = new SpawnItems(CurrentActionIndex);
                    }
                    break;
            }
            if (IsWalking)
            {
                WalkCount += Speed;
                DropGUI d = (DropGUI)Program.SM.States[1].GameGUI[5];

                if (WalkCount >= 64 && Moved)
                {
                    switch (TargetDir)
                    {
                        case 0:
                            CurMap.SpawnedLivingThing[Y + CurMap.MinY][X + CurMap.MinX].Remove(Index);
                            X--;
                            CurMap.SpawnedLivingThing[Y + CurMap.MinY][X + CurMap.MinX].Add(Index);
                            if (this == Logic.CurrentParty.MainParty.MyParty[0])
                            {
                                d.DropX = X + CurMap.MinX;
                                d.DropY = Y + CurMap.MinY;
                            }
                            Moved = false;
                            break;
                        case 1:
                            CurMap.SpawnedLivingThing[Y + CurMap.MinY][X + CurMap.MinX].Remove(Index);
                            Y--;
                            CurMap.SpawnedLivingThing[Y + CurMap.MinY][X + CurMap.MinX].Add(Index);
                            if (this == Logic.CurrentParty.MainParty.MyParty[0])
                            {
                                d.DropX = X + CurMap.MinX;
                                d.DropY = Y + CurMap.MinY;
                            }
                            Moved = false;
                            break;
                        case 2:
                            CurMap.SpawnedLivingThing[Y + CurMap.MinY][X + CurMap.MinX].Remove(Index);
                            X++;
                            CurMap.SpawnedLivingThing[Y + CurMap.MinY][X + CurMap.MinX].Add(Index);
                            if (this == Logic.CurrentParty.MainParty.MyParty[0])
                            {
                                d.DropX = X + CurMap.MinX;
                                d.DropY = Y + CurMap.MinY;
                            }
                            Moved = false;
                            break;
                        case 3:
                            CurMap.SpawnedLivingThing[Y + CurMap.MinY][X + CurMap.MinX].Remove(Index);
                            Y++;
                            CurMap.SpawnedLivingThing[Y + CurMap.MinY][X + CurMap.MinX].Add(Index);
                            if (this == Logic.CurrentParty.MainParty.MyParty[0])
                            {
                                d.DropX = X + CurMap.MinX;
                                d.DropY = Y + CurMap.MinY;
                            }
                            Moved = false;
                            break;
                    }
                }

                if (WalkCount >= 128)
                {
                    switch (TargetDir)
                    {
                        case 0:
                            LastX--;
                            break;
                        case 1:
                            LastY--;
                            break;
                        case 2:
                            LastX++;
                            break;
                        case 3:
                            LastY++;
                            break;
                    }

                    WalkCount = 0;
                    IsWalking = false;

                    if (GeneralBehavior == (int)GeneralBehaviorType.FollowingPath)
                    {
                        if (PathfindingPath.Count > 0)
                        {
                            PathfindingPath.RemoveAt(PathfindingPath.Count - 1);
                            WalkCooldown = 0;
                        }
                    }

                    if (_playerParty > 0)
                        WalkCooldown = 30;
                }
                return;
            }

            else if (PathfindingPath.Count == 0 && GeneralBehavior == (int)GeneralBehaviorType.FollowingPath)
            {
                int tempx = X;
                int tempY = Y;
                switch (ActionDir)
                {
                    case 0:
                        tempx--;
                        break;
                    case 1:
                        tempY--;
                        break;
                    case 2:
                        tempx++;
                        break;
                    case 3:
                        tempY++;
                        break;
                }
                GeneralBehavior = (int)GeneralBehaviorType.Normal;
                /*
                 * 0 = normal
                 * 1 = build
                 * 2 = construction
                 * 3 = craft
                 * 4 = lit fire
                 */
                switch (CurrentAction)
                {
                    case 0:
                        break;
                    case 1:
                        Dir = ActionDir;

                        for (int r = tempY + CurMap.MinY; r < tempY + CurMap.MinY + Program.Data.GetBuildableList()[CurrentActionIndex].SizeY; r++)
                        {
                            for (int c = tempx + CurMap.MinX; c < tempx + CurMap.MinX + Program.Data.GetBuildableList()[CurrentActionIndex].SizeX; c++)
                            {
                                if (Logic.BlockedAt(c, r, CurMap, 1))
                                {
                                    CurrentActionIndex = -1;
                                    CurrentAction = 0;
                                    ActionDir = -1;
                                    return;
                                }
                            }
                        }
                        if (CurMap.NullList.Count > 0)
                        {
                            CurMap.SpawnedSpawnable[CurMap.NullList[0]] = Logic.GetBuildableTypeBasedOnID(CurrentActionIndex, TargetX, TargetY, CurMap);
                            for (int r = TargetY + CurMap.MinY; r < TargetY + CurMap.MinY + Program.Data.GetBuildableList()[CurrentActionIndex].SizeY; r++)
                            {
                                for (int c = TargetX + CurMap.MinX; c < TargetX + CurMap.MinX + Program.Data.GetBuildableList()[CurrentActionIndex].SizeX; c++)
                                {
                                    CurMap.SpawnedSpawnableLocation[r][c] = CurMap.NullList[0];
                                    CurMap.NullList.RemoveAt(0);
                                }
                            }
                        }
                        else
                        {
                            CurMap.SpawnedSpawnable.Add(Logic.GetBuildableTypeBasedOnID(CurrentActionIndex, TargetX, TargetY, CurMap));
                            for (int r = TargetY + CurMap.MinY; r < TargetY + CurMap.MinY + Program.Data.GetBuildableList()[CurrentActionIndex].SizeY; r++)
                            {
                                for (int c = TargetX + CurMap.MinX; c < TargetX + CurMap.MinX + Program.Data.GetBuildableList()[CurrentActionIndex].SizeX; c++)
                                {
                                    CurMap.SpawnedSpawnableLocation[r][c] = CurMap.SpawnedSpawnable.Count - 1;
                                }
                            }
                        }
                        CurrentActionIndex = -1;
                        CurrentAction = 0;
                        ActionDir = -1;
                        ConstructionGUI cg1 = (ConstructionGUI)Program.SM.States[1].GameGUI[9];
                        cg1.LocX = tempx + CurMap.MinX;
                        cg1.LocY = tempY + CurMap.MinY;
                        cg1.Visibility = true;
                        break;
                    case 2:
                        Dir = ActionDir;
                        CurrentAction = 0;
                        ActionDir = -1;
                        ConstructionGUI cg2 = (ConstructionGUI)Program.SM.States[1].GameGUI[9];
                        cg2.LocX = tempx + CurMap.MinX;
                        cg2.LocY = tempY + CurMap.MinY;
                        cg2.Visibility = true;
                        break;
                    case 3:
                        break;
                    case 4:
                        Dir = ActionDir;
                        CurrentAction = 0;
                        ActionDir = -1;
                        SpawnBuildableFire bfire = (SpawnBuildableFire)CurMap.SpawnedSpawnable[CurMap.SpawnedSpawnableLocation[tempY + CurMap.MinY][tempx + CurMap.MinX]];
                        bfire.OnFire = true;
                        break;
                }
            }

            else if (_playerParty > 0)
            {
                if (WalkCooldown == 0)
                {
                    switch ((PartyBehaviorType)_partyBehavior)
                    {
                        case PartyBehaviorType.Roaming:
                            Walk(Logic.RandomNumber(0, 4), true);
                            break;
                        case PartyBehaviorType.FollowTheLeader:
                            if (Logic.CurrentParty.MainParty.MyParty[0].X < X && X - Logic.CurrentParty.MainParty.MyParty[0].X > 1)
                            {
                                Walk(0, true);
                            }
                            else if (Logic.CurrentParty.MainParty.MyParty[0].X > X && Logic.CurrentParty.MainParty.MyParty[0].X - X > 1)
                            {
                                Walk(2, true);
                            }
                            else if (Logic.CurrentParty.MainParty.MyParty[0].Y < Y && Y - Logic.CurrentParty.MainParty.MyParty[0].Y > 1)
                            {
                                Walk(1, true);
                            }
                            else if (Logic.CurrentParty.MainParty.MyParty[0].Y > Y && Logic.CurrentParty.MainParty.MyParty[0].Y - Y > 1)
                            {
                                Walk(3, true);
                            }
                            break;
                    }
                }
                else
                {
                    WalkCooldown--;
                }
                return;
            }

            else if (PlayerParty == 0)
            {
                if (WalkCooldown == 0)
                {
                    if (GeneralBehavior == (int)GeneralBehaviorType.FollowingPath && PathfindingPath.Count > 0)
                    {
                        Walk(PathfindingPath[PathfindingPath.Count - 1], true);
                    }
                }
                else
                    WalkCooldown--;
                //else if (GeneralBehavior == (int)GeneralBehaviorType.Normal)
                //    Walk(Logic.RandomNumber(0, 3));
            }
        }
Пример #5
0
 public void EquipItem(SpawnItems s, ItemType type, int secondary)
 {
     switch (type)
     {
         case ItemType.Ammunition:
             if ((ItemType)Program.Data.MyItems[s.ID].Type == ItemType.Ammunition)
                 Ammunition = s;
             break;
         case ItemType.Armor:
             if ((ItemType)Program.Data.MyItems[s.ID].Type == ItemType.Armor)
                 Armor = s;
             break;
         case ItemType.Helmet:
             if ((ItemType)Program.Data.MyItems[s.ID].Type == ItemType.Helmet)
                 Helmet = s;
             break;
         case ItemType.Boot:
             if ((ItemType)Program.Data.MyItems[s.ID].Type == ItemType.Boot)
                 Boot = s;
             break;
         case ItemType.Cape:
             if ((ItemType)Program.Data.MyItems[s.ID].Type == ItemType.Cape)
                 Cape = s;
             break;
         case ItemType.Bracelet:
             if ((ItemType)Program.Data.MyItems[s.ID].Type == ItemType.Bracelet)
             {
                 if (secondary == 0)
                     Bracelet1 = s;
                 else
                     Bracelet2 = s;
             }
             break;
         case ItemType.Ring:
             if ((ItemType)Program.Data.MyItems[s.ID].Type == ItemType.Ring)
             {
                 if (secondary == 0)
                     Ring1 = s;
                 else
                     Ring2 = s;
             }
             break;
         case ItemType.Storage:
             if ((ItemType)Program.Data.MyItems[s.ID].Type == ItemType.Storage)
                 Storage = s;
             break;
         case ItemType.Weapon:
             if ((ItemType)Program.Data.MyItems[s.ID].Type == ItemType.Weapon)
             {
                 if (secondary == 0)
                     Weapon1 = s;
                 else
                     Weapon2 = s;
             }
             break;
         case ItemType.Necklace:
             if ((ItemType)Program.Data.MyItems[s.ID].Type == ItemType.Necklace)
                 Necklace = s;
             break;
     }
 }