public void SpawnMedKit() { MedKit medKit = _medKitScene.Instance() as MedKit; GetNode("MedKitHolder").AddChild(medKit); medKit.Position = new Vector2(GD.Randi() % 2200, 400); }
public MedKitData Serialize(MedKit medKit) { var medKitData = new MedKitData(); medKitData.medKitType = medKit.GetMedKitType(); medKitData.healthBoost = medKit.GetHealthPointsBoost(); medKitData.slotUiIndex = medKit.GetItemUi().GetItemUiSlotIndex(); return(medKitData); }
public MedKit Deserialize(MedKitData medKitData) { var medKit = new MedKit(medKitData.medKitType, medKitData.healthBoost); var itemUiDataTransfer = new ItemUiDataTransfer(); itemUiDataTransfer.SetItemUiSlotIndex(medKitData.slotUiIndex); medKit.SetItemUi(itemUiDataTransfer); return(medKit); }
void Start() { Player = GameObject.FindGameObjectWithTag("RifleSoldier"); Pm = Player.GetComponent <PlayerMovement_>(); Enemy = GameObject.FindGameObjectWithTag("Teror"); Se = Enemy.GetComponent <ShootingEnemy>(); MedKit = GameObject.FindGameObjectWithTag("Med"); Mk = MedKit.GetComponent <MedKit>(); }
public void HealthPickupTest() { MedKit medikitPickup = new MedKit() { Health = 5 }; player.Health = 1; map[0, 0].placeObject(medikitPickup); new PickupCommand(player).execute(); Assert.AreEqual(6, player.Health); }
// ----- public void RegisterMedkit(MedKit medkit) { if (!medkit || !medkit.Owner) { return; } if (LocalPlayer == null || !medkit.Owner.IsFriend(LocalPlayer.Owner)) { return; } m_RegisteredMedkits.Add(medkit); }
//Inventory inventory = new Inventory(); private void OnTriggerEnter(Collider collider) { Debug.Log("Triggered: " + collider.name); // If it's a MedKit increase health. MedKit kit = collider.GetComponent <MedKit>(); Item item = collider.GetComponent <Item>(); if (item != null) { inventory.InsertItem(item); } if (kit != null) { UpdateHealth(kit.HealingPower); // Find the inventory, find and empy slot, // shove an item at it //inventory.InsertItem(kit); } }
/// <summary> /// Таймер Аптечки. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void MedTimer_Tick(object sender, EventArgs e) { Med = new MedKit(new Point(800, rnd1.Next(0, Game.Height - 100)), new Point(5, 0), new Size(30, 30)); Power = new PowerUp(new Point(800, rnd1.Next(0, Game.Height - 100)), new Point(7, 0), new Size(35, 30)); }
/// <summary> /// Метод обновления положения объектов и их видимости. /// </summary> public static void Update() { foreach (BaseObject str in Stars) { str.Update(); } foreach (Meteor a in Meteor) { if (a.Enable == true) { for (int i = 0; i < BulletList.Count; i++) { if (a.Collision(BulletList.ElementAt(i)) & BulletList.ElementAt(i).Enable == true) { switch (a.Power) { case 0: BulletList.ElementAt(i).Enable = false; PopList.Add(new Pop(new Point(a.GetPosX + 2, a.GetPosY - 2), new Point(0, 0), new Size(1, 1)) { Color = Color.Orange }); a.Enable = false; a.Regenerate(); GameScore += 1; AsteroidScore = GameScore; LogConsole(string.Format("Now your score is: {0}. Time is {1}", GameScore, DateTime.Now - Date)); break; case 3: case 2: case 1: BulletList.ElementAt(i).Enable = false; a.Damage(); break; } } if (BulletList.ElementAt(i).OverScreen()) { BulletList.ElementAt(i).Enable = false; } } if (a.Collision(Ship)) { Ship.DamageEnergy(3); PopList.Add(new Pop(new Point(a.GetPosX, a.GetPosY), new Point(0, 0), new Size(1, 1)) { Color = Color.Blue }); a.Enable = false; a.Regenerate(); LogConsole(string.Format("You get damage! Now your energy is: {0}. Time is {1}", Ship.GetEnergy, DateTime.Now - Date)); } } a?.Update(); } foreach (Bullet b in BulletList) { if (b.Enable == true) { b?.Update(); } } foreach (Pop p in PopList) { if (p.Enable == true) { p.Update(); } } for (int i = 0; i < BulletList.Count; i++) { if (BulletList.ElementAt(i).Enable == false) { BulletList.RemoveAt(i); } } for (int i = 0; i < PopList.Count; i++) { if (PopList.ElementAt(i).Enable == false) { PopList.RemoveAt(i); } } if (Med != null) { if (Ship.Collision(Med)) { Ship.HealthEnergy(10); Med = null; LogConsole(string.Format("You get damage! Now your energy is: {0}. Time is {1}", Ship.GetEnergy, DateTime.Now - Date)); } else if (Med.OverScreen() == true) { Med = null; } Med?.Update(); } if (Power != null) { if (Ship.Collision(Power)) { PowerScore = 100; Power = null; } else if (Power.OverScreen() == true) { Power = null; } Power?.Update(); } if (Ship.GetEnergy <= 0) { Finish(); LogConsole(string.Format("GAMEOVER! Your finall score is: {0}. Time is {1}", GameScore, DateTime.Now - Date)); } Reload(); }
// ----- public void UnregisterMedkit(MedKit medkit) { m_RegisteredMedkits.Remove(medkit); }
private void OnTriggerEnter2D(Collider2D collision) { //Colision con bala de enemigo EnemyShoot enemyShot = collision.gameObject.GetComponent <EnemyShoot>(); if (enemyShot != null) { ChangePlayerLife(enemyShot.damage); Destroy(enemyShot.gameObject); anim.SetTrigger("ReceivePunch"); } EnemyPunch punch = collision.gameObject.GetComponent <EnemyPunch>(); if (punch != null) { ChangePlayerLife(punch.damage); anim.SetTrigger("ReceivePunch"); } Dog dog = collision.gameObject.GetComponent <Dog>(); if (dog != null) { ChangePlayerLife(dog.damage); Destroy(dog.gameObject); anim.SetTrigger("ReceivePunch"); } //Colision con una pistola Pistol pistol = collision.gameObject.GetComponent <Pistol>(); if (pistol != null) { CurrentWeapon = "Pistol"; GunUnlocked = true; Destroy(pistol.gameObject); } //Colision con una macana Knife knife = collision.gameObject.GetComponent <Knife>(); if (knife != null) { CurrentWeapon = "Knife"; KnifeUnlocked = true; Destroy(knife.gameObject); } //Colision con un cuchillo Macana macana = collision.gameObject.GetComponent <Macana>(); if (macana != null) { CurrentWeapon = "Macana"; MacanaUnlocked = true; Destroy(macana.gameObject); } //Colision con medkit MedKit medkit = collision.gameObject.GetComponent <MedKit>(); if (medkit != null) { MedKitFunction(); Destroy(medkit.gameObject); } //Colision con escudo Shield shield = collision.gameObject.GetComponent <Shield>(); if (shield != null) { ShieldFunction(); Destroy(shield.gameObject); } }