Пример #1
0
 public Species(String speciesName, Ecosystem.speciesStats speciesStats, short xPos, short yPos)
 {
     name = speciesName;
     population = 1;
     stats = speciesStats;
     creatures.Add(new Creature(xPos, yPos, speciesStats));
 }
Пример #2
0
        private void updateInput()
        {
            KeyboardState newKS = Keyboard.GetState();
            MouseState newMS = Mouse.GetState();

            // Check for exit.
            if (newKS.IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (newMS.LeftButton.Equals(ButtonState.Pressed))
            {
                // If not down last update, key has just been pressed.
                if (!oldMS.LeftButton.Equals(ButtonState.Pressed))
                {
                    //Creature creation done here for now
                    Ecosystem.speciesStats stats = new Ecosystem.speciesStats();
                    stats.diet = 0;
                    stats.size = 1;
                    stats.detection = 1;
                    stats.speed = 2;
                    stats.energyCap = 100;
                    stats.foodCap = 100;
                    stats.waterCap = 100;
                    ecosystem.addSpecies("mouse", stats, (short)newMS.X, (short)newMS.Y);
                }
            }
            else if (newMS.RightButton.Equals(ButtonState.Pressed))
            {
                // If not down last update, key has just been pressed.
                if (!oldMS.RightButton.Equals(ButtonState.Pressed))
                {
                    //Creature creation done here for now
                    Ecosystem.speciesStats stats = new Ecosystem.speciesStats();
                    stats.diet = 1;
                    stats.size = 1;
                    stats.detection = 1;
                    stats.speed = 2;
                    stats.energyCap = 100;
                    stats.foodCap = 100;
                    stats.waterCap = 100;
                    ecosystem.addSpecies("cat", stats, (short)newMS.X, (short)newMS.Y);
                }
            }
            // Update saved state.
            oldKS = newKS;
            oldMS = newMS;
        }
Пример #3
0
        void mouse_MouseButtonReleased(MouseButtons buttons)
        {
            MouseState ms = mouse.GetState();

            //return if in menu state
            if (baseGame.menuOpen)
            {
                perkTree.mouseClick(ms.X, ms.Y);
            }
            else
            {
                //Temporary debug stuff
                //check not in dialog
                if (ms.X > speciesDialog.Bounds.Left.Fraction * viewport.Width + speciesDialog.Bounds.Left.Offset &&
                    ms.X < speciesDialog.Bounds.Right.Fraction * viewport.Width + speciesDialog.Bounds.Right.Offset &&
                    ms.Y < speciesDialog.Bounds.Bottom.Fraction * viewport.Width + speciesDialog.Bounds.Bottom.Offset &&
                    ms.Y > speciesDialog.Bounds.Top.Fraction * viewport.Width + speciesDialog.Bounds.Top.Offset)
                    return;

                // set up species in here for now
                Ecosystem.speciesStats preyStats = new Ecosystem.speciesStats();

                preyStats.size = Convert.ToInt16(speciesDialog.sizeInput.Text);
                preyStats.detection = Convert.ToInt16(speciesDialog.detectionInput.Text);
                preyStats.speed = Convert.ToInt16(speciesDialog.speedInput.Text);
                preyStats.energyCap = 100;
                preyStats.foodCap = 100;
                preyStats.waterCap = 100;
                preyStats.energyValue = 20;
                preyStats.agility = Convert.ToSingle(speciesDialog.agilityInput.Text);
                if (speciesDialog.colorInput.SelectedItems.Count == 1)
                    switch (speciesDialog.colorInput.Items[speciesDialog.colorInput.SelectedItems[0]])
                    {
                        case "Red":
                            preyStats.color = Color.Red;
                            break;
                        case "Green":
                            preyStats.color = Color.Green;
                            break;
                        case "Blue":
                            preyStats.color = Color.Blue;
                            break;
                        case "Brown":
                            preyStats.color = Color.Brown;
                            break;
                        case "Orange":
                            preyStats.color = Color.Orange;
                            break;
                        default:
                            preyStats.color = Color.White;
                            break;
                    }
                else
                    preyStats.color = Color.White;

                if (speciesDialog.dietInput.SelectedItems.Count == 1)
                    switch (speciesDialog.dietInput.SelectedItems[0])
                    {
                        case 0:
                            preyStats.diet = 0;
                            break;
                        case 1:
                            preyStats.diet = 1;
                            break;
                        case 2:
                            preyStats.diet = 2;
                            break;
                    }
                else
                    preyStats.diet = 0;

                Species newSpecies = ecosystem.addSpecies(speciesDialog.nameInput.Text, preyStats);
                newSpecies.addCreature((int)((ms.X) / baseGame.userView.Z - baseGame.userView.X), (int)((ms.Y) / baseGame.userView.Z - baseGame.userView.Y));
               // newSpecies.addCreature(ms.X - (int)baseGame.userView.X + 10, ms.Y - (int)baseGame.userView.Y);
               // newSpecies.addCreature(ms.X - (int)baseGame.userView.X + 10, ms.Y - (int)baseGame.userView.Y + 10);
              //  newSpecies.addCreature(ms.X - (int)baseGame.userView.X, ms.Y - (int)baseGame.userView.Y + 10);

                speciesDialog.nameInput.Text = "Kleemo" + ecosystem.species.Count.ToString();
            }
        }
Пример #4
0
 public Species(string speciesName, Ecosystem.speciesStats speciesStats)
 {
     name = speciesName;
     population = 1;
     stats = speciesStats;
 }