public Monster(Vector2 position) : base(position) { rect = new Rectangle((int)position.X, (int)position.Y, 32, 32); rotation = MathHelper.ToRadians(Game1.random.Next(0, 360)); gun = new Weapons.SparkerCannon("SparkerCannon", 6); maxVelocity = 5; health = 50; lua = new Lua(); lua.RegisterFunction("SetPosition", this, GetType().GetMethod("SetEntityPosition")); lua.RegisterFunction("GetCenter", this, GetType().GetMethod("GetCenter")); lua.RegisterFunction("GetForce", this, GetType().GetMethod("GetForce")); lua.RegisterFunction("AddForce", this, GetType().GetMethod("AddForce")); lua.RegisterFunction("Seek", this, GetType().GetMethod("Seek")); lua.RegisterFunction("Flee", this, GetType().GetMethod("Flee")); lua.RegisterFunction("Arrive", this, GetType().GetMethod("Arrive")); lua.RegisterFunction("Pursue", this, GetType().GetMethod("Pursue")); lua.RegisterFunction("Evade", this, GetType().GetMethod("Evade")); lua.RegisterFunction("AddSteeringForce", this, GetType().GetMethod("AddSteeringForce")); lua.RegisterFunction("GetPlayer", this, GetType().GetMethod("GetPlayer")); lua.RegisterFunction("DistanceTo", this, GetType().GetMethod("GetDistanceToEntity")); lua.RegisterFunction("GetVelocity", this, GetType().GetMethod("GetEntityVelocity")); lua.RegisterFunction("UpdatePhysics", this, GetType().GetMethod("UpdatePhysics")); lua.RegisterFunction("GetMembers", this, GetType().GetMethod("GetMembers")); lua.RegisterFunction("FireAt", this, GetType().GetMethod("FireAt")); lua.RegisterFunction("Separation", this, GetType().GetMethod("Separation")); lua.DoFile("Scripts/Entity/MonsterAI.lua"); }
// adds current weapon to inventory the empties hand public void RemoveWeapon() { if (weapon1 != null) { inventory.AddItem(new Item.Weapon(weapon1.name)); } weapon1 = null; }
/// <summary> /// gives player weapon and adds current one back to inventory /// </summary> /// <param name="name">name of weapon</param>s public void ChangeWeapon(string name) { if (weapon1 != null) { inventory.AddItem(new Item.Weapon(weapon1.name)); } weapon1 = Weapons.WeaponHelper.GetWeapon(name); }