Esempio n. 1
0
        public Rockguy(Vector2 position)
        {
            HostileType = (int)HostilesTypes.Rockguy;

              Position = position;

              Textures = new Texture2D[]
              {
            Sprites.GetTexture("Planet/Hostiles/Rockguy/Rockguy"),
            Sprites.GetTexture("Planet/Hostiles/Rockguy/RockguyWalking"),
            Sprites.GetTexture("Planet/Hostiles/Rockguy/RockguyPunching")
              };

              DrawBox = new Rectangle(0, 0, 200, 150);
              HitboxSrc = new Rectangle(110, 5, 80, 140);

              State = RockGuyStates.Normal;

              Game1.EventMan.Register(Events.PlayerShootsObj, PlayerShootsObj);
              Game1.EventMan.Register(Events.PlayerStopsShooting, PlayerStopsShooting);
        }
Esempio n. 2
0
        public override void CheckRange(Player player, GameTime gameTime)
        {
            float distanceToPlayer = DistanceXCenter(player);
              Player = player;

              // Normal : Aggro Range : Chase
              // Chase : Punch Range : Chase
              // Chase : Giveup Range : Chase

              bool inAggroRange = distanceToPlayer < AGGRO_RANGE;
              bool inPunchRange = distanceToPlayer < PUNCH_RANGE;
              bool outsideGiveupRange = distanceToPlayer > GIVEUP_RANGE;

              bool canPunch = Game1.CurrentTime - LastPunchHit > PunchCooldown;

              switch (State)
              {
            case RockGuyStates.Normal:
              if (canPunch && inAggroRange)
            State = RockGuyStates.Chasing;

              break;
            case RockGuyStates.Chasing:
              if (canPunch && inPunchRange)
              {
            State = RockGuyStates.Punching;
            LastPunchHit = Game1.CurrentTime;
              }

              if (outsideGiveupRange)
            State = RockGuyStates.Normal;

              break;
            case RockGuyStates.Punching:
              break;
              }
        }
Esempio n. 3
0
        public override void Update(GameTime gameTime)
        {
            switch (State)
              {
            case RockGuyStates.Normal:
              Velocity.X = 0;
              break;

            case RockGuyStates.Chasing:
              if (this.Player != null)
              {
            float px = Player.DrawBox.Center.X - Player.DrawBox.Width / 2;
            float x = DrawBox.Center.X - DrawBox.Width / 2;

            int dir = px < x ? -1 : 1;
            Velocity.X = CHASE_SPEED * dir;
              }
              break;

            case RockGuyStates.Punching:
              if (Game1.CurrentTime - LastPunchHit > PunchRate)
            State = RockGuyStates.Normal;

              Velocity.X = CHASE_SPEED * Direction * 1.5f;
              break;
              }

              UpdateMovement(gameTime);
        }
Esempio n. 4
0
        public override void PlayerShootsObj(object playerObj)
        {
            ActiveObject[] objs = (ActiveObject[])playerObj;

              if (objs[1] == this)
              {
            CurrentlyBeingShot = true;
            State = RockGuyStates.Chasing;
              }
        }