public void LoadWeapon(Items.Weapon weapon, bool isLeft) { Transform par = (isLeft)? leftHand : rightHand; if (isLeft) { leftHandWeapon = weapon; } else { rightHandWeapon = weapon; } GameObject go = weapon.weaponRuntime.modelInstance; if (weapon.weaponRuntime.modelInstance == null) { go = Instantiate(weapon.modelPrefab) as GameObject; weapon.weaponRuntime.modelInstance = go; } go.transform.parent = par; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; go.SetActive(true); }
public void LoadItemsFromStoredIds() { if (rm == null) { rm = Resources.Load("ResourcesManager") as InventoryFramework.ResourcesManager; } for (int i = 0; i < rm.currentIds.Length; i++) { Items.Item it = rm.GetItemInstance(rm.currentIds[i].instId); if (it == null) { if (rm.currentIds[i].bodyPart.isWeapon) { UnEquipWeapon(rm.currentIds[i].isLeft); } else { LoadItemOnPart(null, rm.currentIds[i].bodyPart); } } else if (it is Items.ClothItem) { Items.ClothItem c = (Items.ClothItem)it; LoadItemOnPart(c, rm.currentIds[i].bodyPart); } else if (it is Items.Weapon) { Items.Weapon w = (Items.Weapon)it; LoadWeapon(w, rm.currentIds[i].isLeft); } } }
public void UnEquipWeapon(bool isLeft) { Items.Weapon w = (isLeft) ? leftHandWeapon : rightHandWeapon; if (w == null) { return; } if (w.weaponRuntime.modelInstance) { w.weaponRuntime.modelInstance.SetActive(false); } if (isLeft) { leftHandWeapon = null; } else { rightHandWeapon = null; } }
public Player(Player other) : base(other) { fReboundDuration = other.fReboundDuration; bDrawHealth = other.bDrawHealth; wWeapon = other.wWeapon; //lPsycheQueue = new List<Items.Psyche>(); v2FacingDir = other.v2FacingDir; // ParticleEmitters fShieldDuration = other.fShieldDuration; peShield = new Particle.Emitter(other.peShield); fHealAmount = other.fHealAmount; fHealDuration = other.fHealDuration; peHeal = new Particle.Emitter(other.peHeal); fInvisibleAmount = other.fInvisibleAmount; fInvisibleDuration = other.fInvisibleDuration; peInvisible = new Particle.Emitter(other.peInvisible); // AttackSwing fAttackTimer = other.fAttackTimer; asAttackSprite = new AnimatedSprite(other.asAttackSprite); asAttackSprite.Scale = other.asAttackSprite.Scale; asAttackSprite.Origin = other.asAttackSprite.Origin; //HUD asLeft = new AnimatedSprite(other.asLeft); asRight = new AnimatedSprite(other.asRight); // Sound seAttackSwing = other.seAttackSwing; }
public static Room LoadFile(ContentManager Content, String s_File) { XmlReaderSettings settings = new XmlReaderSettings(); settings.ConformanceLevel = ConformanceLevel.Fragment; settings.IgnoreWhitespace = true; settings.IgnoreComments = true; Room instance = new Room(); using (XmlReader XMLReader = XmlReader.Create(s_File, settings)) { //go through the file finding these nodes and loading them while (XMLReader.Read()) { if (XMLReader.IsStartElement()) { switch (XMLReader.Name) { case "Room": //Console.WriteLine("Start <Room> element."); break; case "AnimatedSprite": //Console.WriteLine("Start <AnimatedSprite> element."); instance.RoomBase = new AnimatedSprite(); instance.RoomBase.xmlImport(XMLReader, Content); break; case "Weapon": //Console.WriteLine("Start <Weapon> element."); Items.Weapon wpn = new Items.Weapon(); wpn.xmlImport(XMLReader, Content); instance.AddItem(wpn); break; case "Psyche": //Console.WriteLine("Start <Psyche> element."); Items.Psyche psy = new Items.Psyche(); psy.xmlImport(XMLReader, Content); instance.AddItem(psy); break; case "Player": //Console.WriteLine("Start <Player> element."); Game1.ePlayer = new Entities.Player(Content); Game1.ePlayer.xmlImport(XMLReader, Content); break; case "Enemy": //Console.WriteLine("Start <Enemy> element."); Entities.Enemy eny = new Entities.Enemy(); eny.xmlImport(XMLReader, Content); instance.AddEntity(eny); break; case "BasicEnemy": //Console.WriteLine("Start <BasicEnemy> element."); Entities.BasicEnemy bsceny = new Entities.BasicEnemy(); bsceny.xmlImport(XMLReader, Content); instance.AddEntity(bsceny); break; case "SpawnerEnemy": //Console.WriteLine("Start <SpawnerEnemy> element."); Entities.SpawnerEnemy swpeny = new Entities.SpawnerEnemy(); swpeny.xmlImport(XMLReader, Content); instance.AddEntity(swpeny); break; case "BossEnemy": //Console.WriteLine("Start <BossEnemy> element."); Entities.BossEnemy bosseny = new Entities.BossEnemy(); bosseny.xmlImport(XMLReader, Content); instance.AddEntity(bosseny); break; case "Obstacle": //Console.WriteLine("Start <Obstacle> element."); Obstacle obs = new Obstacle(); obs.xmlImport(XMLReader, Content); instance.AddObject(obs); break; } } } //Console.WriteLine("End <Room> element."); } return instance; }
public new void xmlImport(XmlReader xml_Reader, ContentManager Content) { //lPsycheQueue.Clear(); while (xml_Reader.Read()) { String attrib; //Console.WriteLine("Player : " + xml_Reader.Name); switch (xml_Reader.Name) { case "Variables": //attrib = xml_Reader["PsycheMax"]; //if (attrib != null) { iPsycheMax = int.Parse(attrib); } attrib = xml_Reader["ItemPickupRange"]; if (attrib != null) { fItemPickupRange = float.Parse(attrib); } attrib = xml_Reader["ShieldDuration"]; if (attrib != null) { fShieldDuration = float.Parse(attrib); } attrib = xml_Reader["HealAmount"]; if (attrib != null) { fHealAmount = float.Parse(attrib); } attrib = xml_Reader["HealDuration"]; if (attrib != null) { fHealDuration = float.Parse(attrib); } attrib = xml_Reader["InvisibleAmount"]; if (attrib != null) { fInvisibleAmount = float.Parse(attrib); } attrib = xml_Reader["InvisibleDuration"]; if (attrib != null) { fInvisibleDuration = float.Parse(attrib); } attrib = xml_Reader["Sound_AttackSwing"]; if (attrib != null) { Content.Load<SoundEffect>(attrib); } break; case "Weapon": wWeapon = new Items.Weapon(); wWeapon.xmlImport(xml_Reader, Content); break; //case "Psyche": //if (lPsycheQueue.Count < iPsycheMax) //{ // Items.Psyche p = new Items.Psyche(); // p.xmlImport(xml_Reader, Content); // lPsycheQueue.Add(p); //} //break; case "AnimatedSprite": asAttackSprite = new AnimatedSprite(); asAttackSprite.xmlImport(xml_Reader, Content); break; case "Entity": base.xmlImport(xml_Reader, Content); break; case "Player": return; } } }
public void AddWeapon(Items.Weapon w_Weapon) { // Add current weapon to room list of items using players position wWeapon.Position = w_Weapon.Position; Rooms.RoomManager.CurrentRoom.Items.Add(new Items.Weapon(wWeapon)); // Set new Weapon as Current Weapon wWeapon = new Items.Weapon(w_Weapon); // Tag the weapon to be removed from the list w_Weapon.ToRemove = true; }
public Player(ContentManager Content, String t2d_Tex = "Entities/Player") : base(Content, t2d_Tex) { fReboundDuration = 200; //rebound duration after attacking in ms bDrawHealth = true; bAttacking = false; HealthCurrent = HealthMax = 20.0f; Speed = 2.0f; UFrameMax = 9; VFrameMax = 1; FrameWidth = Texture.Width / UFrameMax; FrameHeight = Texture.Height / VFrameMax; base.UpdateIndex(); wWeapon = Items.Weapon.FistBasic(Content); //lPsycheQueue = new List<Items.Psyche>(); Origin = new Vector2(FrameWidth / 2, FrameHeight / 2); Position = new Vector2(200, 200); v2FacingDir = new Vector2(1, 0); psCurrentOrb = null;// Items.Psyche.Type.HATE; // Spells // Dispare bShield = false; fShieldDuration = 5.0f; peShield = Particle.Emitter.Shield(Content, fShieldDuration); // Hate bHeal = false; fHealDuration = 1.5f; fHealAmount = 5.0f; peHeal = Particle.Emitter.Heal(Content, fHealDuration); // Misery bInvisible = false; fInvisibleDuration = 2.0f; fInvisibleAmount = 0.2f; peInvisible = Particle.Emitter.Invisible(Content); // Attacking fAttackTimer = wWeapon.Cooldown; asAttackSprite = new AnimatedSprite(Content, "Entities/AttackSwing"); asAttackSprite.Scale = 0.2f; asAttackSprite.Origin = new Vector2(asAttackSprite.FrameWidth / 2, asAttackSprite.FrameHeight / 2); seAttackSwing = Content.Load<SoundEffect>("Entities/Sound/swing04"); //HUD asLeft = new AnimatedSprite(Content, "pixel"); asLeft.Colour = new Color(Color.Black, 1.0f); asLeft.FrameHeight = 32; asLeft.FrameWidth = 32; asLeft.Alpha = 0.2f; asRight = new AnimatedSprite(asLeft); }
public void CheckDropDowns() { //!--WEAPONS--! if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Weapons").GetButton("AxeBasic").Active) { eRoom.Dropdown("Weapons").GetButton("AxeBasic").Active = false; Items.Weapon w = new Items.Weapon((Items.Weapon)eRoom.Dropdown("Weapons").GetObject("AxeBasic")); w.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddItems(w); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Weapons").GetButton("AxeAdv").Active) { eRoom.Dropdown("Weapons").GetButton("AxeAdv").Active = false; Items.Weapon w = new Items.Weapon((Items.Weapon)eRoom.Dropdown("Weapons").GetObject("AxeAdv")); w.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddItems(w); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Weapons").GetButton("DaggerBasic").Active) { eRoom.Dropdown("Weapons").GetButton("DaggerBasic").Active = false; Items.Weapon w = new Items.Weapon((Items.Weapon)eRoom.Dropdown("Weapons").GetObject("DaggerBasic")); w.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddItems(w); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Weapons").GetButton("DaggerAdv").Active) { eRoom.Dropdown("Weapons").GetButton("DaggerAdv").Active = false; Items.Weapon w = new Items.Weapon((Items.Weapon)eRoom.Dropdown("Weapons").GetObject("DaggerAdv")); w.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddItems(w); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Weapons").GetButton("FistBasic").Active) { eRoom.Dropdown("Weapons").GetButton("FistBasic").Active = false; Items.Weapon w = new Items.Weapon((Items.Weapon)eRoom.Dropdown("Weapons").GetObject("FistBasic")); w.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddItems(w); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Weapons").GetButton("FistAdv").Active) { eRoom.Dropdown("Weapons").GetButton("FistAdv").Active = false; Items.Weapon w = new Items.Weapon((Items.Weapon)eRoom.Dropdown("Weapons").GetObject("FistAdv")); w.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddItems(w); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Weapons").GetButton("KatarBasic").Active) { eRoom.Dropdown("Weapons").GetButton("KatarBasic").Active = false; Items.Weapon w = new Items.Weapon((Items.Weapon)eRoom.Dropdown("Weapons").GetObject("KatarBasic")); w.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddItems(w); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Weapons").GetButton("KatarAdv").Active) { eRoom.Dropdown("Weapons").GetButton("KatarAdv").Active = false; Items.Weapon w = new Items.Weapon((Items.Weapon)eRoom.Dropdown("Weapons").GetObject("KatarAdv")); w.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddItems(w); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Weapons").GetButton("MaceBasic").Active) { eRoom.Dropdown("Weapons").GetButton("MaceBasic").Active = false; Items.Weapon w = new Items.Weapon((Items.Weapon)eRoom.Dropdown("Weapons").GetObject("MaceBasic")); w.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddItems(w); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Weapons").GetButton("MaceAdv").Active) { eRoom.Dropdown("Weapons").GetButton("MaceAdv").Active = false; Items.Weapon w = new Items.Weapon((Items.Weapon)eRoom.Dropdown("Weapons").GetObject("MaceAdv")); w.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddItems(w); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Weapons").GetButton("SpearBasic").Active) { eRoom.Dropdown("Weapons").GetButton("SpearBasic").Active = false; Items.Weapon w = new Items.Weapon((Items.Weapon)eRoom.Dropdown("Weapons").GetObject("SpearBasic")); w.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddItems(w); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Weapons").GetButton("SpearAdv").Active) { eRoom.Dropdown("Weapons").GetButton("SpearAdv").Active = false; Items.Weapon w = new Items.Weapon((Items.Weapon)eRoom.Dropdown("Weapons").GetObject("SpearAdv")); w.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddItems(w); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Weapons").GetButton("SwordBasic").Active) { eRoom.Dropdown("Weapons").GetButton("SwordBasic").Active = false; Items.Weapon w = new Items.Weapon((Items.Weapon)eRoom.Dropdown("Weapons").GetObject("SwordBasic")); w.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddItems(w); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Weapons").GetButton("SwordAdv").Active) { eRoom.Dropdown("Weapons").GetButton("SwordAdv").Active = false; Items.Weapon w = new Items.Weapon((Items.Weapon)eRoom.Dropdown("Weapons").GetObject("SwordAdv")); w.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddItems(w); } //!--ENEMIES--! if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Enemies").GetButton("Doctor").Active && eRoom.BasicEnemies.Count <= 10) { eRoom.Dropdown("Enemies").GetButton("Doctor").Active = false; Entities.Enemy e = new Entities.BasicEnemy((Entities.BasicEnemy)eRoom.Dropdown("Enemies").GetObject("Doctor")); e.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddEnemies(e); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Enemies").GetButton("Mental").Active && eRoom.BasicEnemies.Count <= 10) { eRoom.Dropdown("Enemies").GetButton("Mental").Active = false; Entities.Enemy e = new Entities.BasicEnemy((Entities.BasicEnemy)eRoom.Dropdown("Enemies").GetObject("Mental")); e.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddEnemies(e); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Enemies").GetButton("DoctorSpawn").Active && eRoom.Spawners.Count <= 10) { eRoom.Dropdown("Enemies").GetButton("DoctorSpawn").Active = false; Entities.Enemy e = new Entities.SpawnerEnemy((Entities.SpawnerEnemy)eRoom.Dropdown("Enemies").GetObject("DoctorSpawn")); e.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddEnemies(e); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Enemies").GetButton("Boss").Active && eRoom.Bosses.Count <= 4) { eRoom.Dropdown("Enemies").GetButton("Boss").Active = false; Entities.Enemy e = new Entities.BossEnemy((Entities.BossEnemy)eRoom.Dropdown("Enemies").GetObject("Boss")); e.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddEnemies(e); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Enemies").GetButton("MentalSpawn").Active && eRoom.Spawners.Count <= 10) { eRoom.Dropdown("Enemies").GetButton("MentalSpawn").Active = false; Entities.Enemy e = new Entities.SpawnerEnemy((Entities.SpawnerEnemy)eRoom.Dropdown("Enemies").GetObject("MentalSpawn")); e.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddEnemies(e); } //!--PLAYER--! if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Player").GetButton("Player").Active) { eRoom.Dropdown("Player").GetButton("Player").Active = false; Entities.Player p = (Entities.Player)eRoom.Dropdown("Player").GetObject("Player"); p.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddPlayer(p); } //!--OBJECTS--! if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Objects").GetButton("Bed").Active) { eRoom.Dropdown("Objects").GetButton("Bed").Active = false; Rooms.Obstacle o = new Rooms.Obstacle((Rooms.Obstacle)eRoom.Dropdown("Objects").GetObject("Bed")); o.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddObstacle(o); } else if (msMouse.LeftButton == ButtonState.Pressed && eRoom.Dropdown("Objects").GetButton("Chair").Active) { eRoom.Dropdown("Objects").GetButton("Chair").Active = false; Rooms.Obstacle o = new Rooms.Obstacle((Rooms.Obstacle)eRoom.Dropdown("Objects").GetObject("Chair")); o.Position = new Vector2(msMouse.X, msMouse.Y); eRoom.AddObstacle(o); } }