コード例 #1
0
ファイル: Weapon.cs プロジェクト: jreese/snailspace
 /// <summary>
 /// Load a weapon from Lua with the specified name.
 /// </summary>
 /// <param name="name">The name of the weapon.</param>
 /// <returns>The weapon object.</returns>
 public static Weapon load(String name)
 {
     try
     {
         Weapon weapon = new Weapon();
         Engine.lua.CallOn((LuaTable)Engine.lua["Weapons"], name, weapon);
         return weapon;
     }
     catch (LuaException e)
     {
         SnailsPace.debug(e.Message);
         return null;
     }
 }
コード例 #2
0
ファイル: Character.cs プロジェクト: jreese/snailspace
 /// <summary>
 /// Create a character with a specific weapon.
 /// </summary>
 /// <param name="weaponName">The specific weapon for this character.</param>
 public Character(String weaponName)
     : base()
 {
     weapon = Weapon.load(weaponName);
 }
コード例 #3
0
ファイル: Player.cs プロジェクト: jreese/snailspace
        /// <summary>
        /// 
        /// </summary>
        /// <param name="startPosition"></param>
        /// <param name="weaponName"></param>
        public Player(Vector2 startPosition, String weaponName, String nextLevel)
            : base()
        {
            if (allowLevelProgression)
            {
                this.nextLevel = nextLevel;
            }
            else
            {
                this.nextLevel = null;
            }
            saveObject = new GameObject();
            saveObject.affectedByGravity = false;
            saveObject.collidable = false;

            save(startPosition);
            Weapon[] oldInventory = new Weapon[0];
            if (helix != null)
            {
                oldInventory = helix.inventory;
            }
            helix = new Helix(startPosition, weaponName);
            if (SnailsPace.cheatAllWeapons)
            {
                helix.AddWeapon(Weapon.load("stinger"));
                helix.weapon.ammunition = 50;
                helix.weapon.cooldown *= 0.25;
                helix.AddWeapon(Weapon.load("grenadelauncher"));
                helix.weapon.ammunition = 20;
                helix.weapon.cooldown *= 1;
                helix.AddWeapon(Weapon.load("minigun"));
                helix.weapon.ammunition = 200;
                helix.weapon.cooldown *= 4;
                helix.AddWeapon(Weapon.load("flamethrower"));
                helix.weapon.ammunition = 20;
                helix.weapon.cooldown *= 1;
                helix.AddWeapon(Weapon.load("generic"));
            }
            load();

            // Crosshair creation
            Sprite crosshairSprite = new Sprite();
            crosshairSprite.image = new Image();
            crosshairSprite.image.filename = "Resources/Textures/Crosshair";
            crosshairSprite.image.blocks = new Vector2(1.0f, 1.0f);
            crosshairSprite.image.size = new Vector2(64.0f, 64.0f);
            crosshairSprite.visible = true;
            crosshairSprite.effect = "Resources/Effects/effects";
            crosshair = new GameObject();
            crosshair.sprites = new Dictionary<string, Sprite>();
            crosshair.sprites.Add("Crosshair", crosshairSprite);
            crosshair.position = new Vector2(0.0f, 0.0f);
            crosshair.layer = 0;
            crosshair.collidable = false;

            // Weapon
            weapon = new GameObject();
            weapon.sprites = new Dictionary<string, Sprite>();
            weapon.sprites.Add("Weapon", helix.weapon.sprite);
            weapon.position = helix.position;
            weapon.layer = -5;
            weapon.collidable = false;

            strings = new List<Text>();
            pointsText = new Text();
            pointsText.position = new Vector2(400, 0);
            pointsText.font = SnailsPace.getInstance().Content.Load<SpriteFont>("Resources/Fonts/Score");
            pointsText.color = Color.White;
            pointsText.scale = Vector2.One;
            pointsText.content = points.ToString();
            strings.Add(pointsText);
            recalculatePoints();
            Engine.player = this;
            Renderer.cameraTarget = helix;
        }
コード例 #4
0
ファイル: Helix.cs プロジェクト: jreese/snailspace
 /// <summary>
 /// Add a weapon to Helix's inventory, and make it his current weapon.
 /// </summary>
 /// <param name="gun">The new weapon.</param>
 public void AddWeapon(Weapon gun)
 {
     inventory[gun.slot] = gun;
     weapon = gun;
 }