public Item ClosestItem(Dude robot) { float dist = 10000f; Item returnItem = null; foreach (Item i in Items) { if (i.Health > 0f && !i.Dead && i.InWorld && i.Type!= ItemType.Chute) { if ((robot.Position - i.Position).Length() < dist) { dist = (robot.Position - i.Position).Length(); returnItem = i; } } } return returnItem; }
public void CheckChutePickup(Dude dude) { foreach (Item i in Items.Where(it=>it.Type== ItemType.Chute)) { if (i.InWorld && i.Speed.Y==0f && i.Position.Y==i.DroppedPosition.Y) { if (i.Position.X > dude.Position.X - 100f && i.Position.X < dude.Position.X + 100f) { i.InWorld = false; dude.ChuteItem = i; i.Owner = dude; dude.HasParachute = true; //AudioController.PlaySFX("pickup", 1f, 0f, 0f); break; } } } }
public bool CheckAttack(Vector2 pos, int faceDir, float power, float maxDist, int maxHits, Dude attacker) { float mindist = 10000f; int numHits = 0; foreach (Dude r in Enemies.Where(en=>en.IsInPlane && en!=attacker).OrderByDescending(en => en.HasParachute)) { if ((r.Position - pos).Length() < mindist && (r.Position - pos).Length() < maxDist && r.Active && r.knockbackTime<=0) { if ((faceDir == 1 && r.Position.X > pos.X) || (faceDir == -1 && r.Position.X < pos.X)) { numHits++; if (numHits <= maxHits) r.DoHit(pos, power, faceDir, attacker); //mindist = (r.Position - pos).Length(); } } } return (numHits > 0); }
internal void AttemptPickup(Dude dude) { if (dude.Item != null) { Item dropItem = dude.Item; dude.Item = null; dropItem.InWorld = true; dropItem.Position = dude.Position + new Vector2(0, 0); dropItem.DroppedPosition = dude.Position; //AudioController.PlaySFX("pickup", 1f, 0f, 0f); } else { foreach (Item i in Items.OrderBy(it => (it.Position - dude.Position).Length())) { if (i.Health > 0f && !i.Dead && i.InWorld && i.Type != ItemType.Chute) { if (i.Position.X > dude.Position.X - 75f && i.Position.X < dude.Position.X + 75f) { i.InWorld = false; dude.Item = i; i.Owner = dude; //AudioController.PlaySFX("pickup", 1f, 0f, 0f); break; } } } } }
public void Update(GameTime gameTime, Camera gameCamera, Map gameMap, Dude gameHero, float planeRot) { foreach (Item i in Items) { i.Update(gameTime, gameMap, planeRot); } for (int i = Items.Count - 1; i >= 0; i--) { if (Items[i].Dead) Items.RemoveAt(i); } }
public void Spawn(Dude owner, ItemType type, ItemName name) { int item = rand.Next(3); Item newItem = null; newItem = new Item(type, name, itemTex, sourceDict[type.ToString().ToLower()]); newItem.Owner = owner; owner.Item = newItem; Items.Add(newItem); }
void Reset() { currentFade = Color.White * 0f; fadeIn = 1f; particleManager = new ParticleManager(); particleManager.LoadContent(Content); enemyManager = new EnemyManager(); enemyManager.LoadContent(Content, GraphicsDevice); enemyManager.Spawn(gameMap, planeFloorHight); itemManager = new ItemManager(); itemManager.LoadContent(Content, GraphicsDevice); itemManager.SpawnWorld(ItemType.Chute, ItemName.Chute, new Vector2((gameMap.Width * gameMap.TileWidth) - 650f, planeFloorHight-100f)); itemManager.SpawnRandom(10, planeFloorHight); //pilot = new Dude(new Vector2(100,100), true); pilot = new Dude(new Vector2((gameMap.Width * gameMap.TileWidth) - 400f, planeFloorHight), true); pilot.Scale = 2f; pilot.LoadContent(Content, GraphicsDevice); gameCamera.Position = pilot.Position; //sfxEngine.Stop(); sfxPanic.Stop(); sfxWind.Stop(); sfxPanic.Volume = 0.4f; sfxEngine.Volume = 1f; sfxWind.Volume = 0f; sfxEngine.Play(); sfxRattle.Play(); sfxRattle.Pause(); gameState = GameState.Intro; introState = IntroState.FadeIn; introTimer = 0; planeRot = 0f; planeRotTarget = 0f; planeAltitude = 35000; gradHeight = 0f; outroCameraOffset = 0f; tutorialTime = 15000; doorOpen = false; doorFrame = 0; parachuteOpenAmount = 0f; }
public virtual void Use(int faceDir, float attackCharge, Dude gameHero) { coolDownTime = Cooldown; }
public void Spawn(Map gameMap, float floorheight) { //int numSpawned = 0; // Left or right side? Dude d; foreach (MapObject o in ((MapObjectLayer)gameMap.GetLayer("spawns")).Objects) { d = new Dude(new Vector2(o.Location.Center.X, o.Location.Bottom), false); d.faceDir = 1; d.Scale = 2f; d.LoadContent(skeletonRenderer, AtlasDict["dude"], JsonDict["dude"]); Enemies.Add(d); } d = new Dude(new Vector2((gameMap.Width * gameMap.TileWidth) - 380f, floorheight-5), false); d.Tint = Color.Navy; d.faceDir = 1; d.Scale = 2f; d.IsCoPilot = true; d.LoadContent(skeletonRenderer, AtlasDict["dude"], JsonDict["dude"]); d.State = AIState.GoingForDoor; Enemies.Add(d); }
public void Update(GameTime gameTime, Camera gameCamera, Map gameMap, Dude gameHero, float planeRot, bool doorOpen) { foreach (Dude r in Enemies) { r.Update(gameTime, gameMap, gameHero, planeRot, doorOpen); //r.Position = Vector2.Clamp(r.Position, gameCamera.Position - (new Vector2(gameCamera.Width + 300f, gameCamera.Height*2) / 2), gameCamera.Position + (new Vector2(gameCamera.Width + 300f, gameCamera.Height*2) / 2)); } for (int i = Enemies.Count - 1; i >= 0; i--) { if (Enemies[i].Dead) Enemies.RemoveAt(i); } }
//bool CheckCollisionRight(Map gameMap, List<int> levelSectors, Dictionary<int, MapObjectLayer> walkableLayers, int ghs) //{ // for (int i = 0; i < levelSectors.Count; i++) // { // if (i < ghs - 1 || i > ghs + 1) continue; // MapObjectLayer walkableLayer = walkableLayers[levelSectors[i]]; // for (int o = 0; o < walkableLayer.Objects.Count; o++) // { // for(int x=1;x<10;x+=3) // if (Helper.IsPointInShape(new Vector2(Position.X - ((gameMap.Width * gameMap.TileWidth) * i), landingHeight) + new Vector2(x, 0), walkableLayer.Objects[o].LinePoints)) return false; // } // } // return true; //} //bool CheckCollisionLeft(Map gameMap, List<int> levelSectors, Dictionary<int, MapObjectLayer> walkableLayers, int ghs) //{ // for (int i = 0; i < levelSectors.Count; i++) // { // if (i < ghs - 1 || i > ghs + 1) continue; // MapObjectLayer walkableLayer = walkableLayers[levelSectors[i]]; // for (int o = 0; o < walkableLayer.Objects.Count; o++) // { // for (int x = 1; x < 10; x+=3) // if (Helper.IsPointInShape(new Vector2(Position.X - ((gameMap.Width * gameMap.TileWidth) * i), landingHeight) + new Vector2(-x, 0), walkableLayer.Objects[o].LinePoints)) return false; // } // } // return true; //} //bool CheckCollisionUp(Map gameMap, List<int> levelSectors, Dictionary<int, MapObjectLayer> walkableLayers, int ghs) //{ // for (int i = 0; i < levelSectors.Count; i++) // { // if (i < ghs - 1 || i > ghs + 1) continue; // MapObjectLayer walkableLayer = walkableLayers[levelSectors[i]]; // for (int o = 0; o < walkableLayer.Objects.Count;o++) // { // if (Helper.IsPointInShape(new Vector2(Position.X - ((gameMap.Width * gameMap.TileWidth) * i), landingHeight) + new Vector2(0, -10), walkableLayer.Objects[o].LinePoints)) return false; // } // } // return true; //} //bool CheckCollisionDown(Map gameMap, List<int> levelSectors, Dictionary<int, MapObjectLayer> walkableLayers, int ghs) //{ // for (int i = 0; i < levelSectors.Count; i++) // { // if (i < ghs - 1 || i > ghs + 1) continue; // MapObjectLayer walkableLayer = walkableLayers[levelSectors[i]]; // for (int o = 0; o < walkableLayer.Objects.Count; o++) // { // if (Helper.IsPointInShape(new Vector2(Position.X - ((gameMap.Width * gameMap.TileWidth) * i), landingHeight) + new Vector2(0, 10), walkableLayer.Objects[o].LinePoints)) return false; // } // } // return true; //} //Vector2 MoveToRandomPosition(Map gameMap, List<int> levelSectors, Dictionary<int, MapObjectLayer> walkableLayers) //{ // for (int i = 0; i < levelSectors.Count; i++) // { // MapObjectLayer walkableLayer = walkableLayers[levelSectors[i]]; // foreach (MapObject o in walkableLayer.Objects) // { // if (Helper.IsPointInShape(new Vector2((Position.X + 5f) - ((gameMap.Width * gameMap.TileWidth) * i), landingHeight), o.LinePoints) || // Helper.IsPointInShape(new Vector2((Position.X - 5f) - ((gameMap.Width * gameMap.TileWidth) * i), landingHeight), o.LinePoints) || // Helper.IsPointInShape(new Vector2((Position.X) - ((gameMap.Width * gameMap.TileWidth) * i), landingHeight), o.LinePoints)) // { // int lx = 100000; // int ly = 100000; // int mx = -100000; // int my = -100000; // foreach (Point l in o.LinePoints) // { // if (l.X < lx) lx = l.X; // if (l.X > mx) mx = l.X; // if (l.Y < ly) ly = l.Y; // if (l.Y > my) my = l.Y; // } // Vector2 testPoint = new Vector2(lx + (rand.Next(mx - lx)), ly + (rand.Next(my - ly))); // if (Helper.IsPointInShape(testPoint, o.LinePoints)) return testPoint + new Vector2(((gameMap.Width * gameMap.TileWidth) * i),0); // } // } // } // return Position; //} //bool CheckJump(Map gameMap, List<int> levelSectors, Dictionary<int, MapObjectLayer> walkableLayers) //{ // for (int i = 0; i < levelSectors.Count; i++) // { // MapObjectLayer walkableLayer = walkableLayers[levelSectors[i]]; // for (float y = landingHeight - 20; y > landingHeight-300; y--) // { // foreach (MapObject o in walkableLayer.Objects) // { // if (Helper.IsPointInShape(new Vector2((Position.X) - ((gameMap.Width * gameMap.TileWidth) * i), y), o.LinePoints)) // { // return true; // } // } // } // } // return false; //} internal void DoHit(Vector2 pos, float power, int face, Dude attacker) { if (attacker.Item == null) AudioController.PlaySFX("hit_punch", 0.5f, -0.2f, 0.2f, Position); else AudioController.PlaySFX("hit_" + (int)attacker.Item.Name, 0.5f, -0.2f, 0.2f, Position); if (knockbackTime > 0 || !Active) return; if (Health > 1) { if (knockbackTime <= 0) { knockbackTime = 1000f + power; faceDir = -face; if (IsPlayer) knockbackTime *= 0.5; Speed.X = 15f * (float)face; if (jumping) { jumping = false; falling = true; } } Health--; } else { //knockbackTime = 3000f; //knockbackTime = 1000f; deadTime = 1000 + Helper.Random.NextDouble()*4000; faceDir = -face; if (IsPlayer) knockbackTime *= 0.5; Speed.X = 15f * (float)face; Active = false; } //if (IsPlayer) // Health -= (power / 2f); //else //{ // gameHero.Score += (int)power; // Health -= power; //} //AudioController.PlaySFX("hit" + (1 + rand.Next(3)).ToString(), 1f, -0.25f + ((float)rand.NextDouble() * 0.5f), 0f); //AudioController.PlaySFX("thud", 0.8f, 0f, 0f); //ParticleManager.Instance.AddHurt(Position + new Vector2(0, -75f), new Vector2((power / 5f) * face, 0f), landingHeight, tint); //AIchargingAttack = false; //attackCharge = 0f; //if (Health <= 0) //{ // AudioController.PlaySFX("powerdown", 0.5f, 0f, 0f); // if (Item != null) // { // Item.InWorld = true; // Item.Position = Position + new Vector2(0, -75); // Item.DroppedPosition = Position; // Item.Speed.Y = 2f; // Item = null; // } // if (!IsPlayer) // { // gameHero.Score += 500; // if ((int)gameHero.Health < 120) // { // for (int i = 0; i < ((120 - (int)gameHero.Health) / 2) + (rand.Next((120 - (int)gameHero.Health)) / 2); i++) // { // ParticleManager.Instance.Add(ParticleType.Health, Position + new Vector2(0, -75f), (landingHeight - 10f) + ((float)rand.NextDouble() * 20f), new Vector2(-10f + ((float)rand.NextDouble() * 20f), 0), 2000, true, new Rectangle(11, 0, 15, 8), (float)rand.NextDouble() * MathHelper.TwoPi, Color.Red); // } // } // } //} }
public void Update(GameTime gameTime, Map gameMap, Dude gameHero, float planeRot, bool doorOpen) { if (HasParachute) { skeleton.SetAttachment("chute", "chute"); ChuteItem.Position = Position; } else skeleton.SetAttachment("chute", null); if (doorOpen && IsInPlane) { Active = false; animTime += (gameTime.ElapsedGameTime.Milliseconds / 1000f) * 3; Animations["knockback"].Mix(skeleton, animTime, true, 0.3f); if (Position.X > 1350f) Position.X -= 40f; if (Position.X < 1350f) Position.X += 40f; if (Position.X > 1250f && Position.X < 1450f) { IsInPlane = false; fallSpeedX = Helper.RandomFloat(-20f, 0f); } } if (!IsInPlane) { Active = false; animTime += (gameTime.ElapsedGameTime.Milliseconds / 1000f) * 3; Animations["panic"].Mix(skeleton, animTime, true, 0.3f); Position.Y -= (HasParachute?30f:20f); if(!IsPlayer) Position.X += fallSpeedX; } if (Active) { float attackRange = 200f; //if (Item != null) attackRange = Item.Range; if(knockbackTime<=0) ItemManager.Instance.CheckChutePickup(this); if (!IsPlayer) { Item chute = ItemManager.Instance.Items.Where(it => it.Type == ItemType.Chute).First(); justChangedDirTime -= gameTime.ElapsedGameTime.TotalMilliseconds; switch (State) { case AIState.Panic: if (Helper.Random.Next(500) == 0) State = AIState.GoingForParachute; if (Helper.Random.Next(300) == 0) State = AIState.GoingForDoor; if (gameHero.HasParachute && gameHero.Position.X < 3500) { State = AIState.GoingForParachute; } if (Vector2.Distance(chute.Position, Position) < 300f) { State = AIState.GoingForParachute; } if (Helper.Random.Next(100) == 0 && justChangedDirTime < 0) { justChangedDirTime = 1000; targetPosition = new Vector2(200f + Helper.Random.Next((gameMap.Width * gameMap.TileWidth) - 200), Position.Y); } if (targetPosition.X - 50 > Position.X) MoveLeftRight(1); if (targetPosition.X + 50 < Position.X) MoveLeftRight(-1); if (HasParachute) State = AIState.GoingForDoor; break; case AIState.AttackingOther: case AIState.AttackingHero: punchHeldTime += gameTime.ElapsedGameTime.TotalMilliseconds; if (punchHeldTime > 100) { punchReleased = true; punchHeld = false; punchHeldTime = 0; //AudioController.PlaySFX("swipe", 0.5f, -0.1f, 0.1f, Position); } break; case AIState.GoingForDoor: targetPosition = new Vector2(1200f, Position.Y); if (targetPosition.X - 50 > Position.X) MoveLeftRight(1); if (targetPosition.X + 50 < Position.X) MoveLeftRight(-1); break; case AIState.GoingForParachute: if (Vector2.Distance(chute.Position, Position) > 50f) targetPosition = chute.Position; //else targetPosition = Position; if (targetPosition.X - 50 > Position.X) MoveLeftRight(1); if (targetPosition.X + 50 < Position.X) MoveLeftRight(-1); if (HasParachute) State = AIState.GoingForDoor; //if (Helper.Random.Next(500) == 0) State = AIState.Panic; break; } if (State == AIState.GoingForDoor || State == AIState.GoingForParachute || State == AIState.Panic) { if (Helper.Random.Next(200) == 0) { if (EnemyManager.Instance.Enemies.Where(en => (Vector2.Distance(Position, en.Position) < attackRange) && en!=this && en.Active && en.knockbackTime <= 0).Count() > 0) { punchHeld = true; punchHeldTime = 0; State = AIState.AttackingOther; } if (Vector2.Distance(gameHero.Position, Position) < attackRange) { punchHeld = true; punchHeldTime = 0; State = AIState.AttackingHero; } } } if (knockbackTime<0 && Vector2.Distance(targetPosition, Position) < 10f) targetPosition = Position; if ((State == AIState.GoingForDoor || State == AIState.GoingForParachute || State == AIState.Panic) && Item == null) { Item closest = ItemManager.Instance.ClosestItem(this); if(closest!=null && Vector2.Distance(closest.Position, Position)<50f) { Pickup(); } } } if (!walking && !jumping && knockbackTime <= 0) { walkFrameCount = 0; Animations["walk"].Apply(skeleton, 0f, false); if (!IsPlayer && State == AIState.Panic) { Animations["panic"].Mix(skeleton, animTime, true, 0.8f); animTime += (gameTime.ElapsedGameTime.Milliseconds / 1000f) * 2; } } if (walking && !jumping && knockbackTime <= 0) { walkFrameCount++; if (walkFrameCount > 5) { animTime += (gameTime.ElapsedGameTime.Milliseconds / 1000f) * 2; Animations["walk"].Mix(skeleton, animTime, true, 0.3f); } if (!IsPlayer && State == AIState.Panic) Animations["panic"].Mix(skeleton, animTime, true, 0.8f); } if (pickingUp) { pickupTime += gameTime.ElapsedGameTime.TotalMilliseconds; animTime += (gameTime.ElapsedGameTime.Milliseconds / 1000f) * 3; Animations["pickup"].Apply(skeleton, animTime, false); if (pickupTime > 150 && !hasPickedUp) { ItemManager.Instance.AttemptPickup(this); hasPickedUp = true; } if (pickupTime >= 300) { pickingUp = false; hasPickedUp = false; } } if (knockbackTime > 0) { if (HasParachute && ChuteItem != null) { ChuteItem.InWorld = true; ChuteItem.DroppedPosition = Position; ChuteItem.Position = Position + new Vector2(0, -50); ChuteItem.Speed = new Vector2(0f,0.1f); ChuteItem = null; HasParachute = false; } if (Item != null) { Item.InWorld = true; Item.DroppedPosition = Position;// +new Vector2(0, -75); Item.Position = Position + new Vector2(0, -50); Item.Speed = new Vector2(0f,0.1f); Item = null; } knockbackTime -= gameTime.ElapsedGameTime.TotalMilliseconds; animTime += (gameTime.ElapsedGameTime.Milliseconds / 1000f) * 3; Animations["knockback"].Mix(skeleton, animTime, true, 0.3f); // CheckCollision(gameTime, gameMap, levelSectors, walkableLayers, gameHero.Sector); Position += (Speed); if (Speed.X > 0) Speed.X -= 0.1f; else if (Speed.X < 0) Speed.X += 0.1f; if (knockbackTime < 100) State = AIState.Panic; //if (fistSound.Volume > 0f) fistSound.Volume = MathHelper.Clamp(fistSound.Volume -= 0.1f,0f,1f); // if (fistSound.Pitch > -1f) fistSound.Pitch = MathHelper.Clamp(fistSound.Pitch - 0.1f,-0.9f,0.9f); //if (Speed.X > -0.1f && Speed.X < 0.1f) knockbackTime = 0; } else { if (jumping) { Position += JumpSpeed; JumpSpeed += gravity; if (JumpSpeed.Y > 0f) { jumping = false; falling = true; } animTime += gameTime.ElapsedGameTime.Milliseconds / 1000f; //Animations["jump"].Mix(skeleton, animTime, false, 0.5f); } //if (!jumping && !falling) landingHeight = Position.Y; if (punchHeld) { if (Item == null) { Animations["punch-hold"].Apply(skeleton, 1f, false); } else if (Item.Type == ItemType.Melee) { Animations["punch-hold"].Apply(skeleton, 1f, false); } //else if (Item.Type == ItemType.Projectile) //{ // attackCharge += 0.25f; // Animations["punch-release"].Apply(skeleton, 1f, false); // if (IsPlayer || rand.Next(50) == 0) // Item.Use(faceDir, attackCharge, gameHero); //} } else if (punchReleased) { if (Item == null) { if (punchReleaseTime == 0) { //AudioController.PlaySFX("swipe", 0.5f, -0.25f + ((float)rand.NextDouble() * 0.5f), 0f); if (IsPlayer) EnemyManager.Instance.CheckAttack(Position, faceDir, 0f, attackRange, 1, this); else { switch (State) { case AIState.AttackingHero: if ((Position - gameHero.Position).Length() < attackRange && gameHero.IsInPlane) gameHero.DoHit(Position, 0f, faceDir, this); State = AIState.Panic; if (HasParachute) State = AIState.GoingForDoor; break; case AIState.AttackingOther: EnemyManager.Instance.CheckAttack(Position, faceDir, 0f, attackRange, 1, this); State = AIState.Panic; if (HasParachute) State = AIState.GoingForDoor; break; } } } } else if (Item.Type == ItemType.Melee) { if (punchReleaseTime == 0) { //AudioController.PlaySFX("swipe", 0.5f, -0.25f + ((float)rand.NextDouble() * 0.5f), 0f); if (IsPlayer) EnemyManager.Instance.CheckAttack(Position, faceDir, (float)(250 * ((int)Item.Name + 2)), attackRange + (20 * ((int)Item.Name + 2)), (int)Item.Name + 2, this); else { //switch (State) //{ // case AIState.AttackingHero: if ((Position - gameHero.Position).Length() < attackRange + (20 * ((int)Item.Name + 2)) && gameHero.IsInPlane) { gameHero.DoHit(Position, (float)(250 * ((int)Item.Name + 2)), faceDir, gameHero); EnemyManager.Instance.CheckAttack(Position, faceDir, (float)(250 * ((int)Item.Name + 2)), attackRange + (20 * ((int)Item.Name + 2)), (int)Item.Name + 2, this); } else { // break; //case AIState.AttackingOther: EnemyManager.Instance.CheckAttack(Position, faceDir, (float)(250 * ((int)Item.Name + 2)), attackRange + (20 * ((int)Item.Name + 2)), (int)Item.Name + 2, this); // State = AIState.Panic; //break; } State = AIState.Panic; if (HasParachute) State = AIState.GoingForDoor; //} } } } //else if (Item.Type == ItemType.Projectile) //{ // punchReleaseTime = Item.Cooldown; //} punchReleaseTime += gameTime.ElapsedGameTime.TotalMilliseconds; if (punchReleaseTime >= 200) { punchReleaseTime = 0; punchReleased = false; Animations["punch-release"].Apply(skeleton, 0f, false); } Animations["punch-release"].Apply(skeleton, 1f, false); } //attackCharge = MathHelper.Clamp(attackCharge, 0f, 50f); Speed.Normalize(); if (Speed.Length() > 0f) { //CheckCollision(gameTime, gameMap, levelSectors, walkableLayers, gameHero.Sector); if (Speed.Length() > 0f) Position += (Speed * 4f); } Speed = Vector2.Zero; } // else // { // skeleton.SetAttachment("projectile-item", Item.Name); // skeleton.SetAttachment("melee-item", null); // } // //skeleton.FindSlot("fist-item").A = 1f; // if (skeleton.FindSlot("fist-item").A > 0f) skeleton.FindSlot("fist-item").A -= 0.1f; //} //else //{ // if (attackCharge > 0f) // skeleton.FindSlot("fist-item").A = (1f / 50f) * attackCharge; // else // if (skeleton.FindSlot("fist-item").A > 0f) skeleton.FindSlot("fist-item").A -= 0.1f; // skeleton.SetAttachment("fist-item", "fistweap" + (rand.Next(2) + 1).ToString()); // skeleton.SetAttachment("melee-item", null); // skeleton.SetAttachment("projectile-item", null); //} //pushingUp = false; // punchHeld = false; } if (!Active) { if (HasParachute && ChuteItem != null && IsInPlane) { ChuteItem.InWorld = true; ChuteItem.DroppedPosition = Position; ChuteItem.Position = Position + new Vector2(0, -50); ChuteItem.Speed = new Vector2(0f, 0.1f); ChuteItem = null; HasParachute = false; } if (Item != null) { Item.InWorld = true; Item.DroppedPosition = Position;// +new Vector2(0, -75); Item.Position = Position + new Vector2(0, -50); Item.Speed = new Vector2(0f, 0.1f); Item = null; } if (!IsInPlane) { if (!HasParachute) { animTime += (gameTime.ElapsedGameTime.Milliseconds / 1000f); Animations["knockout"].Mix(skeleton, animTime, true, 0.2f); } else Animations["walk"].Apply(skeleton, 0f, true); } else { animTime += (gameTime.ElapsedGameTime.Milliseconds / 1000f); Animations["knockout"].Mix(skeleton, animTime, true, 0.2f); } deadTime -= gameTime.ElapsedGameTime.TotalMilliseconds; //if (deadTime > 0 && deadTime<1000) //{ // //CheckCollision(gameTime, gameMap, levelSectors, walkableLayers, gameHero.Sector); // Position.X += ((float)-faceDir) * (0.001f * (1000f - (float)deadTime)); //} //if (deadTime > 2000 && alpha > 0f) //{ // alpha -= 0.025f; // alpha = MathHelper.Clamp(alpha, 0f, 1f); //} //if (skeleton.FindSlot("fist-item").A > 0f) skeleton.FindSlot("fist-item").A -= 0.1f; if (deadTime <= 0) { Health = 3; Active = true; State = AIState.Panic; deadTime = 0; } } if (Item != null) { if (Item.Type == ItemType.Melee) { skeleton.SetAttachment("melee-item", Item.Name.ToString().ToLower()); } } else skeleton.SetAttachment("melee-item", null); if (falling) { Position += JumpSpeed; JumpSpeed += gravity; } skeleton.A = alpha; foreach (Slot s in skeleton.Slots) { if (s.Data.Name != "melee-item" && s.Data.Name != "projectile-item" && s.Data.Name != "fist-item") { s.A = skeleton.A; } } skeleton.RootBone.ScaleX = Scale; skeleton.RootBone.ScaleY = Scale; collisionRect.Location = new Point((int)Position.X - (collisionRect.Width / 2), (int)Position.Y - (collisionRect.Height)); if (IsInPlane && !doorOpen) { Position.X -= (planeRot * 10f); targetPosition.X -= (planeRot * 10f); Position.X = MathHelper.Clamp(Position.X, 1150, gameMap.Width * gameMap.TileWidth-400f); Position.Y = MathHelper.Clamp(Position.Y, 0, gameMap.Height * gameMap.TileHeight); } skeleton.RootBone.X = Position.X; skeleton.RootBone.Y = Position.Y; if (faceDir == -1) skeleton.FlipX = true; else skeleton.FlipX = false; skeleton.UpdateWorldTransform(); walking = false; // Health = MathHelper.Clamp(Health, 0f, 121f); //if (fistSound.Volume < 0.01f) fistSound.Volume = 0f; }