Inheritance: MonoBehaviour
示例#1
0
    private Weapon RandWeapon()
    {
        Weapon weapon;

        int rand = UnityEngine.Random.Range(1, 40);

        if (rand < 10)
        {
            weapon = new Revolver();
        }
        else if (rand < 20)
        {
            weapon = new Shotgun();
        }
        else if (rand < 30)
        {
            weapon = new Riffle();
        }
        else
        {
            weapon = new Revolver();
        }

        return(weapon);
    }
 void Start()
 {
     gamelogic = GameObject.Find("Logic").GetComponent<GameLogic>();
     shotgun = GetComponent<Shotgun>();
     birdlauncher = GetComponent<BirdLauncher>();
     position = new Rect ((Screen.width - crosshairTexture.width) / 2, (Screen.height - crosshairTexture.height) / 2, crosshairTexture.width/2, crosshairTexture.height/2);
 }
示例#3
0
    // Declare member variables here. Examples:
    // private int a = 2;
    // private string b = "text";

    // Called when the node enters the scene tree for the first time.

    public override void _Draw()
    {
        if (tower != null)
        {
            DrawEmptyCircle(tower.GetPosition() + new Vector2(12, 12), new Vector2(tower.GetRange(), tower.GetRange()), Color.ColorN("white"), circleVisualizerResolution);
            if (tower is Shotgun)
            {
                Shotgun shot   = tower as Shotgun;
                float   spread = shot.GetSpreadDegrees();

                Vector2 dir = Vector2.Right;

                DrawLine(
                    tower.GetPosition() + new Vector2(12, 12),
                    tower.GetPosition() + new Vector2(12, 12) + tower.GetRange() * dir.Rotated(Mathf.Deg2Rad(-spread / 2)),
                    Color.ColorN("white")
                    );
                DrawLine(
                    tower.GetPosition() + new Vector2(12, 12),
                    tower.GetPosition() + new Vector2(12, 12) + tower.GetRange() * dir.Rotated(Mathf.Deg2Rad(spread / 2)),
                    Color.ColorN("white")
                    );
            }
        }
    }
    private void OnEnable()
    {
        _controller     = GetComponent <ControllableObject>();
        _collisionState = GetComponent <PlayerCollisionState>();

        _shotgunGO = GetComponentInChildren <Shotgun>();
    }
示例#5
0
        public static void AddNewSkladStorage(string NameFaction)
        {
            const int Pistols  = 1000;
            const int Rifle    = 1000;
            const int SMG      = 1500;
            const int Shotgun  = 2500;
            const int Melee    = 2500;
            const int Armor    = 2500;
            const int Medicals = 2500;

            switch (NameFaction)
            {
            case "Start":

                Dictionary <string, string> parametersStatr = new Dictionary <string, string>
                {
                    { "@NameFaction", NameFaction },
                    { "@Pistols", Pistols.ToString() },
                    { "@Rifle", Rifle.ToString() },
                    { "@SMG", SMG.ToString() },
                    { "@Shotgun", Shotgun.ToString() },
                    { "@Melee", Melee.ToString() },
                    { "@Armor", Armor.ToString() },
                    { "@Medicals", Medicals.ToString() }
                };

                DataTable resultStatr = Database.ExecutePreparedStatement("INSERT INTO sklad_faction_storages (NameFaction, Pistols, Rifle, SMG, Shotgun, Melee, Armor, Medicals) " +
                                                                          DatabaseValues, parametersStatr);

                break;
            }
        }
示例#6
0
    public void DoAction()
    {
        Splittable cube = gameObject.GetComponent <Splittable> ();

        if (cube)
        {
            cube.Split();
        }
        Spawner spawn = gameObject.GetComponent <Spawner> ();

        if (spawn)
        {
            spawn.Spawn();
        }
        Sweeper sweep = gameObject.GetComponent <Sweeper> ();

        if (sweep)
        {
            sweep.Sweep();
        }
        Shotgun shotgun = gameObject.GetComponent <Shotgun> ();

        if (shotgun)
        {
            shotgun.Shoot();
        }
    }
示例#7
0
文件: Playar_Attack.cs 项目: j4ra/FPS
 // Use this for initialization
 void Start()
 {
     machineGun = GetComponent<MachineGun>();
     rocketLauncher = GetComponent<RocketLauncher>();
     gun = GetComponent<Gun>();
     shotgun = GetComponent<Shotgun>();
 }
        public ConcreteMediator()
        {
            minigun      = new Minigun(this);
            assaultRifle = new AssaultRifle(this);
            flamethrower = new Flamethrower(this);
            shotgun      = new Shotgun(this);
            sniperRifle  = new SniperRifle(this);

            assaultRifleGreen = new AssaultRifle(this);
            new GreenLaser(assaultRifleGreen, this);
            assaultRifleRed = new AssaultRifle(this);
            new RedLaser(assaultRifleRed, this);

            sniperRifleGreen = new SniperRifle(this);
            new GreenLaser(sniperRifleGreen, this);
            sniperRifleRed = new SniperRifle(this);
            new RedLaser(sniperRifleRed, this);

            weaponsList = new List <Weapon>();
            weaponsList.Add(minigun);
            weaponsList.Add(assaultRifle);
            weaponsList.Add(flamethrower);
            weaponsList.Add(shotgun);
            weaponsList.Add(sniperRifle);
            weaponsList.Add(assaultRifleGreen);
            weaponsList.Add(assaultRifleRed);
            weaponsList.Add(sniperRifleGreen);
            weaponsList.Add(sniperRifleRed);
        }
 private void OnTriggerExit2D(Collider2D col)
 {
     if (col.tag == "Player")
     {
         playerEntered = false;
         _sg           = null;
     }
 }
 private void OnTriggerEnter2D(Collider2D col)
 {
     if (col.tag == "Player")
     {
         playerEntered = true;
         _sg           = col.gameObject.GetComponentInChildren <Shotgun>();
     }
 }
示例#11
0
 void Start()
 {
     controls      = GetComponent <Controls>();
     m_playerStats = GetComponent <PlayerStats>();
     m_Shotgun     = GetComponent <Shotgun>();
     m_Animator    = GetComponentInChildren <Animator>();
     l_bullets     = 0;
 }
 public void selectshotgun()
 {
     Fire_Button.shotgun = true;
     Difficulty.count    = Difficulty.count - 2;
     decrement           = true;
     Shotgun.SetActive(true);
     Assault.SetActive(false);
 }
 // Start is called before the first frame update
 void Start()
 {
     decrement = false;
     Assault.SetActive(true);
     Revolver.SetActive(false);
     Shotgun.SetActive(false);
     animator = panel.GetComponent <Animator>();
 }
示例#14
0
        static void Main(string[] argv)
        {
            Weapon AK47   = new Rife("AK 47", 200, 100);
            Weapon SawOff = new Shotgun("SawOff", 500, 150);
            Weapon Mp5    = new SMG("Mp5", 150, 200);

            AK47.fire();
        }
示例#15
0
 private void Start()
 {
     hud = GameObject.FindGameObjectWithTag("HUD").GetComponent <HUD>();
     hud.healthText.text = Health.ToString();
     pM           = gameObject.GetComponent <PlayerMovement>();
     lastHealth   = Health;
     activeWeapon = weapon.GetComponent <Shotgun>();
 }
        public void TestEnemyIsAlive()
        {
            Weapon testWeapon = new Shotgun();
            Enemy  testEnemy  = new Sergeant();

            testWeapon.Shoot(testEnemy);
            Assert.IsTrue(testEnemy.Alive);
        }
示例#17
0
    void Start()
    {
        gameMarker          = GameObject.Find("Game Root/GameMarker");
        currentStunDuration = maxStunDuration;
        myRigidbody         = GetComponent <Rigidbody2D>();
        players.Add(gameObject);
        playerHitState        = gameObject.AddComponent <PlayerHitState>() as PlayerHitState;
        playerHitState.player = gameObject;
        GameObject vulcanObject = Instantiate(Resources.Load("Vulcan"), transform.position, Quaternion.identity) as GameObject;

        vulcanObject.transform.parent = transform;
        vulcan        = vulcanObject.GetComponent <Vulcan>() as Vulcan;
        vulcan.player = this;
        GameObject bombLauncherObject = Instantiate(Resources.Load("Bomb Launcher"), transform.position, Quaternion.identity) as GameObject;

        bombLauncherObject.transform.parent = transform;
        bombLauncher         = bombLauncherObject.GetComponent <BombLauncher>() as BombLauncher;
        bombLauncher.player  = this;
        shotgun              = gameObject.AddComponent <Shotgun>() as Shotgun;
        shotgun.player       = this;
        gigaBeam             = gameObject.AddComponent <GigaBeam>() as GigaBeam;
        gigaBeam.player      = this;
        magnetMissile        = gameObject.AddComponent <MagnetMissile>() as MagnetMissile;
        magnetMissile.player = this;
        reversePosition      = GetComponent <Entity>().affinity.GetComponent <Fleet>().reversePosition;
        body = transform.Find("Body").gameObject;
        body.GetComponent <SpriteRenderer>().color = GetComponent <Entity>().affinity.GetComponent <Fleet>().teamColor;
        shieldObject = Instantiate(shieldPrefab, transform.position, Quaternion.identity) as GameObject;
        shieldObject.transform.parent = gameObject.transform;
        shield        = shieldObject.GetComponent <Shield>();
        shield.player = this;
        playerHitState.SwitchToInvincible();
        damageBehavior = GetComponent <DamageBehavior>();
        currentExValue = GetComponent <Entity>().affinity.GetComponent <Fleet>().lastExValue;
        gameObject.transform.eulerAngles = new Vector3(
            gameObject.transform.eulerAngles.x,
            gameObject.transform.eulerAngles.y,
            gameObject.transform.eulerAngles.z - 90);
        vehicleControls = GetComponent <VehicleControls>();
        if (reversePosition)
        {
            reverseIndex *= -1;
        }
        GameObject playerHud = Instantiate(Resources.Load("HUD/PlayerHUD"), transform.position, Quaternion.identity) as GameObject;

        playerHud.transform.parent = GameObject.Find("WorldspaceHUD").transform;
        playerHud.GetComponent <PlayerHUD>().player = this;
        defaultColor = body.GetComponent <SpriteRenderer>().color;
        foreach (Transform child in body.transform)
        {
            CarWheel wheel = child.GetComponent <CarWheel>();
            if (wheel)
            {
                wheel.vehicleControls = vehicleControls;
            }
        }
        currentExValue = maxExValue;
    }
示例#18
0
    private void LevelComplete()
    {
        // Display GameOver screen with score based on ammo left
        int score = Pistol.GetAmmoCount() + Cannon.GetAmmoCount() * 5 + Shotgun.GetAmmoCount() / 5;

        timer.gameOver    = true;
        gameOverText.text = "Good job!";
        scoreText.text    = "Score: " + score;
    }
    // Start is called before the first frame update
    void Start()
    {
        pistol  = GetComponentInChildren <Pistol>();
        shotgun = GetComponentInChildren <Shotgun>();
        rifle   = GetComponentInChildren <AssaultRifle>();

        ReloadStatus();
        SelectWeapon();
    }
 public void selectassault()
 {
     if (decrement == true)
     {
         Difficulty.count = Difficulty.count + 2;
     }
     Shotgun.SetActive(false);
     Assault.SetActive(true);
 }
 /// <summary>
 /// Use this for initialisation.
 /// </summary>
 void Start()
 {
     anim           = GetComponent <Animator>();
     _AudioSource   = GetComponent <AudioSource>();
     fps1           = GameObject.FindObjectOfType <FPSController>();
     shotgun        = GameObject.FindObjectOfType <Shotgun>();
     currentBullets = bulletsPerMag;
     wm             = gameObject.GetComponentInParent(typeof(WeaponManager)) as WeaponManager;
 }
 public static void ResetGame()
 {
     Scoring.blocksLeft = 7;
     timer.Reset();
     mode.currentMode = mode.savedMode;
     buildHeightCheck.buildHeightReached = false;
     Pistol.ResetAmmo();
     Cannon.ResetAmmo();
     Shotgun.ResetAmmo();
 }
示例#23
0
 public void Init(Player player, PlayerStats playerStats, Handgun handgun, Shotgun shotgun, Machinegun machinegun, ControlsController controls, SignalBus bus)
 {
     _player      = player;
     _playerStats = playerStats;
     _handgun     = handgun;
     _shotgun     = shotgun;
     _machinegun  = machinegun;
     _controls    = controls;
     _bus         = bus;
 }
        public void ShootTankWithGunThatDoesNotDamage()
        {
            Weapon testWeapon = new Shotgun();
            Enemy  testEnemy  = new Tank();

            testWeapon.Shoot(testEnemy);
            int test = Tank.Tank_Starting_Energy;

            Assert.AreEqual(test, testEnemy.EnergyRemaining);
        }
示例#25
0
        public void ShootGruntWithShotgun()
        {
            Weapon testWeapon = new Shotgun();
            Enemy  testEnemy  = new Grunt();

            testWeapon.Shoot(testEnemy);
            int test = Grunt.Grunt_Starting_Energy - Shotgun.Shotgun_Damage_Points;

            Assert.AreEqual(test, testEnemy.EnergyRemaining);
        }
示例#26
0
 void SetComponents()
 {
     gunFireAudioSource = GetComponent <AudioSource>();
     spriteRenderer     = GetComponent <SpriteRenderer>();
     gameObject.AddComponent <PlayerController>();
     gun     = GetComponent <Gun>();
     shotgun = GetComponent <Shotgun>();
     rifle   = GetComponent <Rifle>();
     rpg     = GetComponent <Rpg>();
     sniper  = GetComponent <Sniper>();
 }
示例#27
0
    private void EnablePickup()
    {
        switch (_thisItem)
        {
        case _itemType.Handgun:
            Handgun playerHandgun = weaponManager.GetComponentInChildren <Handgun>(true);
            if (playerHandgun.CurrentAmmo < playerHandgun.MagazineCapacity + 1)   // Check if we have less than 1 clip left, if so then respawn ammo, add +1 in case user is running around with one magazine left in ammo reserve
            {
                GetComponent <ParticleSystem>().Play();
                GetComponent <Collider>().enabled = true;
                _pickupMesh.SetActive(true);
                CancelInvoke("EnablePickup");     // Make sure to cancel the invoke
            }
            break;

        case _itemType.Shotgun:
            Shotgun playerShotgun = weaponManager.GetComponentInChildren <Shotgun>(true);
            if (playerShotgun.CurrentAmmo < playerShotgun.MagazineCapacity * 2)     // Check if we have less than 1 clip left, if so then respawn ammo
            {
                GetComponent <ParticleSystem>().Play();
                GetComponent <Collider>().enabled = true;
                _pickupMesh.SetActive(true);
                CancelInvoke("EnablePickup");
            }
            break;

        case _itemType.PlasmaRifle:
            PlasmaRifle playerPlasmaRifle = weaponManager.GetComponentInChildren <PlasmaRifle>(true);
            if (playerPlasmaRifle.CurrentAmmo < playerPlasmaRifle.MagazineCapacity)     // Check if we have less than 1 clip left, if so then respawn ammo
            {
                GetComponent <ParticleSystem>().Play();
                GetComponent <Collider>().enabled = true;
                _pickupMesh.SetActive(true);
                CancelInvoke("EnablePickup");
            }
            break;

        case _itemType.HealthPickup:
            if (PlayerStats.PlayerHealth <= 30.0f)
            {
                GetComponent <ParticleSystem>().Play();
                GetComponent <Collider>().enabled = true;
                _pickupMesh.SetActive(true);
            }

            break;

        case _itemType.AmmoPickup:
            break;

        default:
            break;
        }
    }
示例#28
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            // get the weapons of the player, even if they are inactive

            Pistol       pistol  = player.GetComponentInChildren(typeof(Pistol), true) as Pistol;
            AssaultRifle rifle   = player.GetComponentInChildren(typeof(AssaultRifle), true) as AssaultRifle;
            Shotgun      shotgun = player.GetComponentInChildren(typeof(Shotgun), true) as Shotgun;

            if (ammoSprite == sprites[0])
            {
                WeaponAmmo ammo = pistol.GetComponent <WeaponAmmo>();
                if (ammo.currentReserveAmmo != ammo.maxReserveAmmo)
                {
                    pickUpSound.Play();
                    ammo.currentReserveAmmo = ammo.currentReserveAmmo + (ammoMultiplier * ammo.maxMag);
                    if (ammo.currentReserveAmmo > ammo.maxReserveAmmo)
                    {
                        ammo.currentReserveAmmo = ammo.maxReserveAmmo;
                    }
                    StartCoroutine(DeleteObject());
                }
            }
            else if (ammoSprite == sprites[1])
            {
                WeaponAmmo ammo = rifle.GetComponent <WeaponAmmo>();
                if (ammo.currentReserveAmmo != ammo.maxReserveAmmo)
                {
                    pickUpSound.Play();
                    ammo.currentReserveAmmo = ammo.currentReserveAmmo + (ammoMultiplier * ammo.maxMag);
                    if (ammo.currentReserveAmmo > ammo.maxReserveAmmo)
                    {
                        ammo.currentReserveAmmo = ammo.maxReserveAmmo;
                    }
                    StartCoroutine(DeleteObject());
                }
            }
            else if (ammoSprite == sprites[2])
            {
                WeaponAmmo ammo = shotgun.GetComponent <WeaponAmmo>();
                if (ammo.currentReserveAmmo != ammo.maxReserveAmmo)
                {
                    pickUpSound.Play();
                    ammo.currentReserveAmmo = ammo.currentReserveAmmo + (ammoMultiplier * ammo.maxMag);
                    if (ammo.currentReserveAmmo > ammo.maxReserveAmmo)
                    {
                        ammo.currentReserveAmmo = ammo.maxReserveAmmo;
                    }
                    StartCoroutine(DeleteObject());
                }
            }
        }
    }
示例#29
0
    public static void SaveShotgun(Shotgun shotgun)
    {
        BinaryFormatter formatter = new BinaryFormatter();                        // allows conversion to a binary format
        string          sFilePath = Application.persistentDataPath + "/SMG.sdat"; // creates a persistant path to the save file meaning it doesn't get moved around the system

        FileStream stream = new FileStream(sFilePath, FileMode.Create);           // create the save file on the system

        ShotgunSaveData shotgunData = new ShotgunSaveData(shotgun);               // get the player information defined in the PlayerData.cs script

        formatter.Serialize(stream, shotgunData);                                 // serialize our data into a binary format
        stream.Close();                                                           // close our stream to stop leaks
    }
示例#30
0
        /// <summary>
        /// Se llama cada vez que hay que refrescar la pantalla.
        ///     Escribir aquí todo el código referido al renderizado.
        /// </summary>
        /// <param name="gameTime">The gameTime<see cref="GameTime"/>.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            var mouse = Mouse.GetState();

            if (mouse.LeftButton == ButtonState.Pressed && Recoil == 0)
            {
                Recoil = 10;
            }
            if (mouse.RightButton == ButtonState.Pressed && Recoil == 0)
            {
                Recoil = 13.5f;
            }

            Map.Draw(World, Camera.View, Camera.Projection);

            SpawnerModel.Draw(Camera.View, Camera.Projection);

            foreach (Enemy enemy in Enemies)
            {
                if (enemy.GetLife() > 0)
                {
                    Vector3 SkullRight    = Vector3.Cross(enemy.GetDirection(), enemy.GetUp());
                    Vector3 SkullPosition = enemy.GetPosition() + enemy.GetDirection() + SkullRight - enemy.GetUp();
                    Skull.Draw(Matrix.CreateScale(0.75f) * Matrix.CreateWorld(SkullPosition, -SkullRight, enemy.GetUp()), Camera.View, Camera.Projection);
                }
            }

            foreach (Bullet bullet in Bullets)
            {
                Vector3 BulletRight    = Vector3.Cross(bullet.GetDirection(), bullet.GetUp());
                Vector3 BulletPosition = bullet.GetPosition() + bullet.GetDirection() + BulletRight - bullet.GetUp();
                if (Vector3.Distance(bullet.GetPosition(), Camera.Position) < 2550)
                {
                    BulletModel.Draw(Matrix.CreateScale(5) * Matrix.CreateWorld(BulletPosition, -BulletRight, bullet.GetDirection()), Camera.View, Camera.Projection);
                }
            }

            if (Recoil > 0)
            {
                Recoil -= 0.25f;
            }

            Vector3 cameraRight    = Vector3.Cross(Camera.FrontDirection, Camera.UpDirection);
            Vector3 weaponPosition = new Vector3(Camera.Position.X, 0, Camera.Position.Z) + new Vector3(0, -15, 0) + Camera.FrontDirection * MathHelper.Lerp(40, 35, Recoil) + cameraRight * 10 - Camera.UpDirection * 4;
            Matrix  shotgunWorld   = Matrix.CreateScale(0.1f, 0.1f, 0.1f) * Matrix.CreateWorld(weaponPosition, -cameraRight, Camera.UpDirection);

            Shotgun.Draw(shotgunWorld, Camera.View, Camera.Projection);

            base.Draw(gameTime);
        }
示例#31
0
        static void Main(string[] args)
        {
            Console.WriteLine("This is Tyra Oberholzer's Quiz 07.");
            IFirearm s = new Shotgun();

            s.doWhat("shotgun", "BOOM");
            IFirearm r = new Rifle();

            r.doWhat("rifle", "BANG");
            IFirearm p = new Pistol();

            p.doWhat("pistol", "POP");
        }
示例#32
0
        static void Main(string[] args)
        {
            Console.WriteLine("Quiz 7");
            IFirearm s = new Shotgun();

            s.stuff("shotgun", "Boom");
            IFirearm r = new Rifle();

            r.stuff("rifle", "Bang");
            IFirearm p = new Pistol();

            p.stuff("Pistol", "Pop");
        }
示例#33
0
 public void addWeapon(Types type, int efficiencyPercentage)
 {
     switch (type)
     {
         case Types.Pistol:
             weapons[(int)type] = new Pistol(efficiencyPercentage);
             break;
         case Types.Shotgun:
             weapons[(int)type] = new Shotgun(efficiencyPercentage);
             break;
         case Types.RocketLauncher:
             weapons[(int)type] = new RocketLauncher(efficiencyPercentage);
             break;
     }
 }
示例#34
0
	// Use this for initialization
	public void Init () {
		weapons = new ArrayList ();

		Pistol pistol = new Pistol ();
		pistol.bulletType = bulletType;
		weapons.Add (pistol);

		Shotgun shotgun = new Shotgun ();
		shotgun.bulletType = bulletType;
		weapons.Add (shotgun);
		currentWeaponIndex = 0;

		ammo = new ArrayList ();
		ammo.Add (new Ammo (17, 34, 17));
		ammo.Add (new Ammo (3, 9, 3));
		updateAmmoLabel ();
	}
示例#35
0
 public void addWeapon(Types type, float[] characteristics)
 {
     switch (type)
     {
         case Types.Pistol:
             weapons[(int)type] = new Pistol(characteristics);
             GameObject.Find("__GUIDisplayer").GetComponent<GUIDisplayer>().pistolIndicator.enabled = true;
             break;
         case Types.Shotgun:
             weapons[(int)type] = new Shotgun(characteristics);
             GameObject.Find("__GUIDisplayer").GetComponent<GUIDisplayer>().shotgunIndicator.enabled = true;
             break;
         case Types.RocketLauncher:
             weapons[(int)type] = new RocketLauncher(characteristics);
             GameObject.Find("__GUIDisplayer").GetComponent<GUIDisplayer>().rocketLauncherIndicator.enabled = true;
             break;
     }
     changeSelectedWeapon(type);
 }
示例#36
0
 void Start()
 {
     gameMarker = GameObject.Find("Game Root/GameMarker");
     currentStunDuration = maxStunDuration;
     myRigidbody = GetComponent<Rigidbody2D>();
     players.Add (gameObject);
     playerHitState = gameObject.AddComponent<PlayerHitState>() as PlayerHitState;
     playerHitState.player = gameObject;
     GameObject vulcanObject = Instantiate (Resources.Load ("Vulcan"), transform.position, Quaternion.identity) as GameObject;
     vulcanObject.transform.parent = transform;
     vulcan = vulcanObject.GetComponent<Vulcan>() as Vulcan;
     vulcan.player = this;
     GameObject bombLauncherObject = Instantiate (Resources.Load ("Bomb Launcher"), transform.position, Quaternion.identity) as GameObject;
     bombLauncherObject.transform.parent = transform;
     bombLauncher = bombLauncherObject.GetComponent<BombLauncher>() as BombLauncher;
     bombLauncher.player = this;
     shotgun = gameObject.AddComponent<Shotgun>() as Shotgun;
     shotgun.player = this;
     gigaBeam = gameObject.AddComponent<GigaBeam>() as GigaBeam;
     gigaBeam.player = this;
     magnetMissile = gameObject.AddComponent<MagnetMissile>() as MagnetMissile;
     magnetMissile.player = this;
     reversePosition = GetComponent<Entity>().affinity.GetComponent<Fleet>().reversePosition;
     body = transform.Find ("Body").gameObject;
     body.GetComponent<SpriteRenderer>().color = GetComponent<Entity>().affinity.GetComponent<Fleet>().teamColor;
     shieldObject = Instantiate (shieldPrefab, transform.position, Quaternion.identity) as GameObject;
     shieldObject.transform.parent = gameObject.transform;
     shield = shieldObject.GetComponent<Shield>();
     shield.player = this;
     playerHitState.SwitchToInvincible();
     damageBehavior = GetComponent<DamageBehavior>();
     currentExValue = GetComponent<Entity>().affinity.GetComponent<Fleet>().lastExValue;
     gameObject.transform.eulerAngles = new Vector3(
         gameObject.transform.eulerAngles.x,
         gameObject.transform.eulerAngles.y,
         gameObject.transform.eulerAngles.z - 90);
     vehicleControls = GetComponent<VehicleControls>();
     if(reversePosition) reverseIndex *= -1;
     GameObject playerHud = Instantiate (Resources.Load ("HUD/PlayerHUD"), transform.position, Quaternion.identity) as GameObject;
     playerHud.transform.parent = GameObject.Find ("WorldspaceHUD").transform;
     playerHud.GetComponent<PlayerHUD>().player = this;
     defaultColor = body.GetComponent<SpriteRenderer>().color;
     foreach(Transform child in body.transform){
         CarWheel wheel = child.GetComponent<CarWheel>();
         if(wheel){
             wheel.vehicleControls = vehicleControls;
         }
     }
     currentExValue = maxExValue;
 }
示例#37
0
文件: ShopUI.cs 项目: jadmz/RobotRPG
 //Stuff that's on the gui
 void OnGUI()
 {
     //The scrap counter
     GUI.Box (new Rect (10, 10, 100, 30), player.ScrapMetal.ToString());
     //Display this if the shop is open
     if(menuOn)
     {
         GUI.skin = null;
         GUI.Box (new Rect(190, 60, 1020, 700), "");
         GUI.skin = robotSkin;
         //Displays the main shop menu
         if(baseLevel)
         {
             //Switches to weapons level
             if (ShopBlock (new Rect(200,285,1000,120),generalWeaponPicture, weaponsCategory, weaponsCatergoryDescription,
                 categoryPrice, categoryButtonText))
             {
                 baseLevel = false;
                 weaponsBaseLevel = true;
             }
             // Switches to powers menu
             if (ShopBlock (new Rect(200,415,1000,120),generalPowerPicture, powersCategory, powersCategoryDescription,
                 categoryPrice, categoryButtonText))
             {
                 baseLevel = false;
                 powersBaseLevel = true;
             }
         }
         //The weapon upgrade level
         if(weaponsBaseLevel)
         {
             //Tries to buy an upgrade for the basic weapon
             if(ShopBlock (new Rect(200,285,1000,120), firstWeaponPicture, firstWeaponName, firstWeaponDescription, firstWeaponPrice,
                 buyText))
             {
                 //try to buy it
                 //upgrade the weapon
                 if(tryBuy (firstWeaponPrice))
                 {
                     player.Guns[basicGunIndex].upgrade (player);
                 }
                 Debug.Log (player.gunDamage());
             }
             //Tries to buy the shotgun or upgrade it
             if (ShopBlock (new Rect(200,415,1000,120),secondWeaponPicture, secondWeaponName, secondWeaponDescription,
                 secondWeaponPrice, buyText))
             {
                 //Upgrades the shotgun if it is bought
                 if(weapon2Bought)
                 {
                     if(tryBuy (secondWeaponPrice))
                     {
                         player.Guns[shotgunIndex].upgrade (player);
                     }
                 }
                 //Buys the shotgun
                 else
                 {
                     if(tryBuy (secondWeaponPrice))
                     {
                         Shotgun shotgun = new Shotgun();
                         player.Guns.Add (shotgun);
                         shotgunIndex = player.Guns.IndexOf (shotgun);
                         weapon2Bought = true;
                     }
                 }
             }
         }
         //The "powers" menu
         if(powersBaseLevel)
         {
             GUI.Box(new Rect(200, 285, 1000, 120), "Powers not yet authorized! Pay 1600 Joe Bucks for powers DLC!");
             if(GUI.Button (new Rect(200, 415, 1000, 120), "I'm too poor, back to main menu."))
             {
                 powersBaseLevel = false;
                 baseLevel = true;
             }
         }
     }
 }