Beispiel #1
0
        public Nest(Texture2D texture, ContentManager content, Point position, short id, Point mapDimensions, Point tileDimensions, Point playerSpawn, bool[,] passable)
        {
            _id = id;
            rand = new Random(DateTime.Now.Millisecond);
            _texture = texture;
            _position = new Vector2(position.X, position.Y);

            _moveArea = new Rectangle((int)(_position.X / tileDimensions.X) - (MOVE_AREA_SIZE / 2), (int)(_position.Y / tileDimensions.Y) - (MOVE_AREA_SIZE / 2), MOVE_AREA_SIZE, MOVE_AREA_SIZE);
            if(_moveArea.X < 0)
                _moveArea.X = 0;
            if(_moveArea.Y < 0)
                _moveArea.Y = 0;
            if (_moveArea.X + MOVE_AREA_SIZE > mapDimensions.X)
                _moveArea.Width = mapDimensions.X;
            if (_moveArea.Y + MOVE_AREA_SIZE > mapDimensions.Y)
                _moveArea.Height = mapDimensions.Y;

            for (int i = 0; i < MAX_CREATURES; i++)
            {
                Point Position;

                do
                {
                    Position = new Point(rand.Next(_moveArea.X, _moveArea.X + _moveArea.Width),
                        rand.Next(_moveArea.Y, _moveArea.Y + _moveArea.Height));
                } while ((Position == playerSpawn || Position.X < 0 || Position.X > mapDimensions.X || Position.Y < 0 || Position.Y > mapDimensions.Y
                    || passable[Position.X, Position.Y] == false) && Position == Point.Zero);

                // Decide on creature texture based on abillities
                Creature creature = new Creature(id, content.Load<Texture2D>("Sprites/Creatures/CreatureGeneric"), new Vector2(Position.X * tileDimensions.X, Position.Y * tileDimensions.Y), 1f, 32, 32, 100);
                if (creature.canFly)
                    creature.SetTexture(content.Load<Texture2D>("Sprites/Creatures/flyingCreature"));
                if(creature.canSwim)
                    creature.SetTexture(content.Load<Texture2D>("Sprites/Creatures/swimmingCreature"));

                creatures.Add(creature);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Breeds two creatures together.
        /// </summary>
        /// <param name="A">Parent No1</param>
        /// <param name="B">Parent No2</param>
        public Creature(Creature A, Creature B, Texture2D texture, Vector2 position2D, float moveSpeed, int frameWidth, int frameHeight, int millisecondsBetweenFrame)
            : base(texture, position2D, moveSpeed, frameWidth, frameWidth, millisecondsBetweenFrame)
        {
            StatsUShort[] Health = IntMethod(A.Dominant.Health, B.Dominant.Health, A.Recessive.Health, B.Recessive.Health);
            Dominant.Health = Health[0];
            Recessive.Health = Health[1];

            StatsUShort[] Weight = IntMethod(A.Dominant.Weight, B.Dominant.Weight, A.Recessive.Weight, B.Recessive.Weight);
            Dominant.Weight = Weight[0];
            Recessive.Weight = Weight[1];

            StatsUShort[] Size = IntMethod(A.Dominant.Size, B.Dominant.Size, A.Recessive.Size, B.Recessive.Size);
            Dominant.Size = Size[0];
            Recessive.Size = Size[1];

            StatsUShort[] Strength = IntMethod(A.Dominant.Strength, B.Dominant.Strength, A.Recessive.Strength, B.Recessive.Strength);
            Dominant.Strength = Strength[0];
            Recessive.Strength = Strength[1];

            StatsUShort[] Dexterity = IntMethod(A.Dominant.Dexterity, B.Dominant.Dexterity, A.Recessive.Dexterity, B.Recessive.Dexterity);
            Dominant.Dexterity = Dexterity[0];
            Recessive.Dexterity = Dexterity[1];

            StatsUShort[] Endurance = IntMethod(A.Dominant.Endurance, B.Dominant.Endurance, A.Recessive.Endurance, B.Recessive.Endurance);
            Dominant.Endurance = Endurance[0];
            Recessive.Endurance = Endurance[1];

            StatsUShort[] Speed = IntMethod(A.Dominant.Speed, B.Dominant.Speed, A.Recessive.Speed, B.Recessive.Speed);
            Dominant.Speed = Speed[0];
            Recessive.Speed = Speed[1];

            float AvgRecUsed = (A.RecessiveGenesBoolUsedAvg + B.RecessiveGenesBoolUsedAvg) / 2;

            StatsBool[] Head = BoolMethod(A.Dominant.Head, B.Dominant.Head, A.Recessive.Head, B.Recessive.Head, AvgRecUsed);
            Dominant.Head = Head[0];
            Recessive.Head = Head[1];
            StatsBool[] Legs = BoolMethod(A.Dominant.Legs, B.Dominant.Legs, A.Recessive.Legs, B.Recessive.Legs, AvgRecUsed);
            Dominant.Legs = Legs[0];
            Recessive.Legs = Legs[1];
            StatsBool[] Arms = BoolMethod(A.Dominant.Arms, B.Dominant.Arms, A.Recessive.Arms, B.Recessive.Arms, AvgRecUsed);
            Dominant.Arms = Arms[0];
            Recessive.Arms = Arms[1];
            StatsBool[] Wings = BoolMethod(A.Dominant.Wings, B.Dominant.Wings, A.Recessive.Wings, B.Recessive.Wings, AvgRecUsed);
            Dominant.Wings = Wings[0];
            Recessive.Wings = Wings[1];
            StatsBool[] Claws = BoolMethod(A.Dominant.Claws, B.Dominant.Claws, A.Recessive.Claws, B.Recessive.Claws, AvgRecUsed);
            Dominant.Claws = Claws[0];
            Recessive.Claws = Claws[1];

            // Reset Used on breed creature.
            if (Dominant.Head.Active)
                Dominant.Head.Used = 0;
            if (Dominant.Legs.Active)
                Dominant.Legs.Used = 0;
            if (Dominant.Arms.Active)
                Dominant.Arms.Used = 0;
            if (Dominant.Wings.Active)
                Dominant.Wings.Used = 0;
            if (Dominant.Claws.Active)
                Dominant.Claws.Used = 0;

            avTacks = new AttackTypes(Dominant);
            CreateModel();
        }
Beispiel #3
0
 /// <summary>
 /// Adds DNA to the owned DNA.
 /// </summary>
 /// <param name="newDNA">The new DNA data.</param>
 public void AddDNA(Creature newDNA)
 {
     dna.Add(newDNA);
 }
Beispiel #4
0
 /// <summary>
 /// Use the currently selected DNA. If selectedDNA is null, this function does nothing. (Use SetDNA(int indexInList) to set the selected DNA).
 /// </summary>
 public void UseDNA()
 {
     if (selectedDNA != null)
     {
         dna.Remove(selectedDNA);
         GameHandler.Player = new Creature(GameHandler.Player, selectedDNA, GameHandler.Player.Texture, GameHandler.Player.Position, GameHandler.Player.MoveSpeed, 32, 32, 100);
         selectedDNA = null;
     }
 }
Beispiel #5
0
 /// <summary>
 /// Sets the selected DNA to an element in the list of owned DNA. (Use UseDNA() to use the selected DNA)
 /// </summary>
 /// <param name="indexInList">The index in the list in which the DNA is located.</param>
 public void SetDNA(int indexInList)
 {
     selectedDNA = dna[indexInList];
 }
Beispiel #6
0
 /// <summary>
 /// Clears any selections made in a menu
 /// </summary>
 public void ClearSelections()
 {
     if (selectedDNA != null)
         selectedDNA = null;
     if (selectedItem != null)
         selectedItem = null;
 }