public AddPosition ( Vector2 pos, int posId = -1 ) : |
||
pos | Vector2 | |
posId | int | |
return |
public override void Load(ContentManager content) { Vector2 percentPos = new Vector2(330 * characterModel.playerIndex + 30, Constants.WindowHeight - 120); thumb = new ImageView(content.Load <Texture2D>(GamePadControllers[characterModel.playerIndex].PlayerModel.SelectedCharacter.thumbnail), percentPos, 159, true); thumb.Scale = 0.6f; AddView(thumb); percentBox = new TextBox("0%", GetFont("Impact.large"), percentPos + new Vector2(180, 40), Color.White, 1f); percentBox.StaticPosition = true; percentBox.Layer = 150; percentBox.Origin = new Vector2(20, 0); AddView(percentBox); percentBg = new ImageView(content.Load <Texture2D>("GameStuff/PlayerPercentBg"), percentPos + new Vector2(0, 94), 149, true); AddView(percentBg); if (gameOptions.UseLifes) { lifes = new ImageController(Screen, "GameStuff/Life", 160, true); AddController(lifes); for (int i = 0; i < gameOptions.Lifes; i++) { lifes.AddPosition(percentPos + new Vector2(i * 16 + 130, 100), 400); } } }
/// <summary> /// Show the character at bottom of screen when cursor hovers a characterThumb /// </summary> private void hoverCharacter(int playerIndex, int characterIndex) { //Get the character model CharacterStats chModel = characterModels[characterIndex]; //Get character pose by using index ImageController img = characterImages[characterIndex]; //Checks if player already has an entry for hovered character //Removes the hovered character if (characterHover.ContainsKey(playerIndex)) { img.RemovePosition(characterHover[playerIndex]); } //If not hovered character add playerIndex to dictionary else { characterHover.Add(playerIndex, null); } ImageModel model = img.AddPosition(playerIndex * 260, 720, playerIndex); model.Id = characterIndex; img.AnimatePos(model, playerIndex * 260, 450, 300); characterHover[playerIndex] = model; //characterThumbs[index].Scale = 1.05f; characterThumbs[characterIndex].AnimateScale(1.1f, 500); characterThumbs[characterIndex].GetAt(0).CurrentRotation = 0.05f; img.IsVisible = true; }
public void StartMove(Vector2 characterPosition, Vector2 characterVelocity, MoveModel move) { if (!move.Started) { move.Img = Img.AddPosition(characterPosition + move.Stats.SqFrom * move.Xdirection); move.Img.SetBoundBox(World, (int)move.Stats.SqSize.X, (int)move.Stats.SqSize.Y, Vector2.Zero, Category.Cat20, Category.Cat11); move.Img.BoundBox.IgnoreGravity = true; move.Img.BoundBox.IsStatic = false; move.Img.BoundBox.UserData = move; move.Started = true; if (move.Stats.Type == MoveType.Range) { move.Img.BoundBox.LinearVelocity = move.Stats.BulletVelocity * move.Xdirection; Img.AnimateFrame(move.Img, move.Stats.AniBulletFrom, move.Stats.AniBulletTo, 14); //if (move.Xdirection == new Vector2(-1, 1)) move.Img. if (move.Stats.Gravity) { move.Img.BoundBox.IgnoreGravity = false; } move.Img.BoundBox.CollidesWith = Category.Cat11 | Category.Cat10 | Category.Cat9 | Category.Cat8 | Category.Cat7; if (move.Stats.Explotion != null) { move.Img.BoundBox.CollisionCategories = Category.Cat31; } move.Img.BoundBox.OnCollision += Collision; } else { Vector2 velocity = ConvertUnits.ToSimUnits((move.Stats.SqTo - move.Stats.SqFrom) / (move.Stats.End - move.Stats.Start) * 1000) * move.Xdirection; velocity = move.Stats.SqFrom == move.Stats.SqTo ? characterVelocity : velocity + characterVelocity; move.Img.BoundBox.LinearVelocity = velocity; move.Img.CurrentFrame = -1; } } }
private void OnPlayerHit(Vector2 pos, int damageDone, int newDamagepoints, int puncher, int reciever, string sound) { Screen.soundController.PlaySound(sound); this.players[puncher].DidHit(damageDone, reciever); this.players[reciever].GotHit(newDamagepoints, puncher); Random r = new Random(); ImageModel inf = effectImg.AddPosition(pos); inf.CurrentFrame = r.Next(0, 4); effectImg.AnimateScale(inf, 0.7f, 200); }
/// <summary> /// Adds new random powerup to the map insise the drop zone /// </summary> public void addPowerUpToMap() { ImageModel model = powerUpImg.AddPosition(randomDropPosition()); model.SetBoundBox(World, 50, 50, Vector2.Zero, Category.Cat6, Category.All); model.BoundBox.OnCollision += OnCollision; powerUpImg.AnimateScale(model, 1f, 400, false); elapsedTime = 0; generateTimeToNext(); PowerUpStatus status = new PowerUpStatus(randomPowerUp(), model); model.BoundBox.UserData = status; //model.CurrentFrame = (int)MathHelper.Clamp(status.PowerUp.imageFrame, 0f, 3f); waitingPowerUps.Add(status); }
public override void Load(ContentManager content) { Vector2 percentPos = new Vector2(330 * characterModel.playerIndex + 30, Constants.WindowHeight - 120); thumb = new ImageView(content.Load<Texture2D>(GamePadControllers[characterModel.playerIndex].PlayerModel.SelectedCharacter.thumbnail), percentPos, 159, true); thumb.Scale = 0.6f; AddView(thumb); percentBox = new TextBox("0%", GetFont("Impact.large"), percentPos + new Vector2(180, 40), Color.White, 1f); percentBox.StaticPosition = true; percentBox.Layer = 150; percentBox.Origin = new Vector2(20, 0); AddView(percentBox); percentBg = new ImageView(content.Load<Texture2D>("GameStuff/PlayerPercentBg"), percentPos + new Vector2(0, 94), 149, true); AddView(percentBg); if (gameOptions.UseLifes) { lifes = new ImageController(Screen, "GameStuff/Life", 160, true); AddController(lifes); for (int i = 0; i < gameOptions.Lifes; i++) { lifes.AddPosition(percentPos + new Vector2(i * 16 + 130, 100), 400); } } }