Inheritance: MonoBehaviour
 void Awake() {
     anim = GetComponent<Animator>();
     playerAudio = GetComponent<AudioSource>();
     playerMovement = GetComponent<PlayerMovement>();
     playerShooting = GetComponentInChildren<PlayerShooting>();
     currentHealth = startingHealth;
 }
Ejemplo n.º 2
0
 void Awake()
 {
     playerHealth = GetComponent<PlayerHealth>();
     playerLevel = GetComponent<PlayerLevel>();
     playerPerks = GetComponent<PlayerPerks>();
     playerShooting = GetComponent<PlayerShooting>();
     playerMovement = GetComponent<PlayerMovement>();
 }
Ejemplo n.º 3
0
 void Awake()
 {
     anim = GetComponent <Animator> (); //Gets a reference to the animator
     playerAudio = GetComponent <AudioSource> (); //Gets a reference to the audiosource
     playerMovement = GetComponent <PlayerMovement> (); //Gets a reference to the playermovement script
     playerShooting = GetComponentInChildren <PlayerShooting> (); //Get the components of the shooting script since it fires on the end of the gunbarrel
     currentHealth = startingHealth; //Sets current health to starter health
 }
Ejemplo n.º 4
0
 void Awake()
 {
     anim = GetComponent<Animator>();
     playerAudio = GetComponent<AudioSource>();
     playerShooting = GetComponentInChildren<PlayerShooting>();
     fps = GetComponent<FirstPersonController>();
     currentHealth = startingHealth;
 }
 //Animator anim;
 //bool shooting;
 // Use this for initialization
 void Start()
 {
     print ("cube start()");
     _shooting = _gun.GetComponent<PlayerShooting>();
     c_AudioSource = GetComponent<AudioSource>();
     gazeAt = false;
     stareAt(gazeAt);
 }
Ejemplo n.º 6
0
 void Awake()
 {
     rb = GetComponent<Rigidbody> ();
     anim = GetComponent<Animator> ();
     audioController = GetComponent<AudioController> ();
     rb.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
     cam = Camera.main.transform;
     gun = transform.GetComponentInChildren<PlayerShooting> ();
 }
Ejemplo n.º 7
0
 void Awake()
 {
     anim = GetComponent <Animator> ();
     playerAudio = GetComponent <AudioSource> ();
     playerMovement = GetComponent <PlayerMovement> ();
     playerShooting = GetComponentInChildren <PlayerShooting> ();
     currentHealth = startingHealth;
     mainCamera = GameObject.Find ("Main Camera").GetComponent<Camera>();
     Player2Camera = GameObject.Find ("Main Camera 2").GetComponent<Camera>();
 }
Ejemplo n.º 8
0
    void Start()
    {
        for (int i = 0; i < 6 ; i++) {
            transform.GetChild (i).GetComponent<CharacterSlot> ().index = i;
        }

        player = GameObject.FindGameObjectWithTag ("Player");
        playerHealth = player.GetComponent<PlayerHealth> ();
        playerShooting = player.GetComponentInChildren<PlayerShooting>();
    }
Ejemplo n.º 9
0
 // Use this for initialization
 void Start()
 {
     for (int i = PlayerPrefs.GetInt("Duplicate") - 1; i > 0; --i)
     {
         CreateDuplicate();
     }
     playerShootingScript = GetComponent<PlayerShooting>();
     lives = GameObject.Find("Lives").GetComponent<UILives>(); //eww
     score = GameObject.Find("PlayerInfo").GetComponent<UIScore>(); //double eww
 }
Ejemplo n.º 10
0
    void Awake()
    {
        // Setting up the references.
        anim = GetComponent<Animator>();
        playerAudio = GetComponent<AudioSource>();
        playerShooting = GetComponentInChildren<PlayerShooting>();

        // Set the initial health of the player.
        currentHealth = startingHealth;
    }
Ejemplo n.º 11
0
    void Awake()
    {
        hearts = GameObject.Find("HealthUI").GetComponentsInChildren<Image>();
        damageImage = GameObject.Find ("Damage Image").GetComponent<Image> ();

        animPlayer = GetComponent < Animator > ();
        playerAudio = GetComponents < AudioSource > ();

        playerMovement = GetComponent < PlayerMovement > ();
        playerShooting = GetComponentInChildren < PlayerShooting > ();
    }
Ejemplo n.º 12
0
    void Awake()
    {
        floorMask = LayerMask.GetMask("Floor");
        animChar = GetComponent < Animator > ();
        animHUD = GameObject.Find ("HUDCanvas").GetComponent < Animator > ();
        playerRigidbody = GetComponent < Rigidbody > ();
        playerAudio = GetComponents < AudioSource > ();

        playerGun = GetComponent < PlayerGun > ();
        playerShooting = GetComponentInChildren<PlayerShooting> ();
    }
    //METHODS (OFTEN USED)
    void Awake()
    {
        // Setting up the references.
        _anim = GetComponent <Animator> ();
        _playerAudio = GetComponent <AudioSource> ();
        _playerMovement = GetComponent <Player> ();
        _playerShooting = GetComponentInChildren <PlayerShooting> (); //referencing to the child of Player: "gun barrel".

        // Set the starting health of the player.
        currentHealth = startingHealth;
    }
Ejemplo n.º 14
0
 public void Awake()
 {
     //Initialize components
     player = GameObject.FindWithTag("Player");
     rifleTip = GameObject.Find("RifleTip");
     gunLine = rifleTip.GetComponent<LineRenderer>();
     gunLight = rifleTip.GetComponent<Light>();
     playerShooting = rifleTip.GetComponent<PlayerShooting>();
     playerStamina = player.GetComponent<PlayerStamina>();
     rend = GameObject.FindWithTag("RendPlayer").GetComponent<Renderer>();
 }
Ejemplo n.º 15
0
 void Awake()
 {
     damageImage = GameObject.FindGameObjectWithTag("DamageImage").GetComponent<Image> ();
     healthSlider = CreateHealthBar ();
     anim = GetComponent <Animator> ();
     playerAudio = GetComponent <AudioSource> ();
     playerMovement = GetComponent <PlayerMovement> ();
     playerShooting = GetComponentInChildren <PlayerShooting> ();
     capsuleCollider = GetComponent <CapsuleCollider> ();
     sphereCollider = GetComponent<SphereCollider> ();
     currentHealth = startingHealth;
 }
Ejemplo n.º 16
0
    void Awake()
    {
        currentHealth = startingHealth;

        playerController = GetComponent<PlayerController>();
        playerShooting = GetComponent<PlayerShooting>();

        damaged = false;

        healthSlider = GameObject.FindWithTag("HealthSliderHUD").GetComponent<Slider>();

        flashImage = GameObject.Find("DamageSplash").GetComponent<Image>();
    }
Ejemplo n.º 17
0
    void Awake()
    {
        gun = GameObject.FindGameObjectWithTag ("GunBarrelEnd");
        playerShooting = gun.GetComponent <PlayerShooting> ();

        bullet = gun.GetComponent<ParticleSystem> ();
        yellow = bullet.startColor;
        bulletLine = gun.GetComponent<LineRenderer> ();
        lineYellow = bulletLine.material.GetColor ("_TintColor");

        playerIsStrong = false;
        playerInRange = false;
        player = GameObject.FindGameObjectWithTag ("Player");
    }
Ejemplo n.º 18
0
    void Awake()
    {
        if(instance==null){
            instance=this;
        }else if(instance!=this){
            Destroy(gameObject);
        }

        shootableMask = LayerMask.GetMask ("Shootable");
        gunParticles = GetComponent<ParticleSystem> ();
        gunLine = GetComponent <LineRenderer> ();
        gunAudio = GetComponent<AudioSource> ();
        gunLight = GetComponent<Light> ();
    }
Ejemplo n.º 19
0
    void Awake()
    {
        currentHealth = InitialHealth;

        PlayerShooting = GetComponentInChildren <PlayerShooting> ();

        HealthSlider = GameObject.Find("HealthBar").GetComponent<Slider>();

        PlayerSoundFX = GetComponents<AudioSource> ();									//GetComponents gives multi value
            HurtClip = PlayerSoundFX[0];
            DeadClip = PlayerSoundFX[1];

        PlayerHurtImage = GameObject.Find ("PlayerHurtImage").GetComponent<RawImage>();

        DeadBloodParticleSystem = GetComponentInChildren<ParticleSystem>();

        PlayerManager = GameObject.Find ("PlayerMan").GetComponent<PlayerManager>();
    }
Ejemplo n.º 20
0
    /// <summary>
    /// Get Player Detail like Player Health, Player Movement and Player Shoot to disable when
    /// Game is over
    /// </summary>
    void Awake()
    {
        Player = GameObject.Find("Police");													//Find Police GameObj
        PoliceHealth = Player.GetComponent<PlayerHealth>();									//Get PlayerHealth Script from Police
        playerMovement = Player.GetComponent<PlayerMovement>();								//Get PlayerMovement
        playerShooting = Player.GetComponentInChildren <PlayerShooting>();					//Get the Playershooting from GunBarrel i.e child of player
        PlayerAnimator = Player.GetComponent<Animator>();									//Get the animator component from player

        LevelManager = GameObject.Find("LevelManager").GetComponent<LevelMan>();			//Get the LevelMan Script from LevelManager GameObj

        ZombieFinder = GameObject.FindGameObjectsWithTag("ZombieTag");						//Find all the Alive zombie

        HealthSlider = HUD.GetComponentInChildren<Slider>();								//Get the Health Slider from HealthBar Canvas

        HeartImage = GameObject.Find ("HeartImage").GetComponent<Image>();					// Get the Image from HeartImage UI
                //Get the Sprite Image from LifeImage Array
                SecondLife = LifeImage[0];
                ThirdLife = LifeImage[1];
                ForthLife = LifeImage[2];

        MissionOver = GameObject.Find ("DayComplete").GetComponent<Image>();				//Get DayComplete Gameobj

        MissionOver.color = Color.clear;													//Set Image transparent
    }
Ejemplo n.º 21
0
	bool damaged;                                               // True when the player gets damaged.
	
	
	void Awake ()
	{
		playerMovement = GetComponent <PlayerMovement> ();
		playerShooting = GetComponentInChildren <PlayerShooting> ();
		currentHealth = startingHealth; // Set the initial health of the player.
	}
Ejemplo n.º 22
0
    void Update()
    {
        if (blockInputTimer >= 0)
        {
            blockInputTimer -= Time.deltaTime;
            return;
        }
        switch (state)
        {
        case MenuState.TitleScreen:
            Vector2 input = GenericInput.GetLeftStickMovement(gamepads);

            titleScreenMovement.Move(input.x, input.y, false);
            if (MenuInput.GetStartKeyDown(gamepads))
            {
                PlayerShooting shooting = titleScreenMovement.GetComponent <PlayerShooting>();
                shooting.Aim(mainMenuLocation.x, mainMenuLocation.y, 0, 0);
                shooting.Draw();
                shooting.Shoot();
                //Play camera script
                //Load menu
                state = MenuState.MainMenu;
                //TODO: Transition time
                blockInputTimer = .5f;
                Logger.Log("Player select", this, LogLevel.Log);
            }
            break;

        case MenuState.MainMenu:
            state = MenuState.PlayerSelect;
            break;

        case MenuState.PlayerSelect:
            for (int i = 0; i < GM.MAXPLAYERCOUNT; i++)
            {
                if (controllerPlayerIDMapping[i] == -1)
                {
                    if (MenuInput.GetSelectKeyDown(gamepads[i]))
                    {
                        //register player
                        controllerPlayerIDMapping[i] = GM.GameInstance.AddPlayer(i);
                        Logger.Log("Added controller: " + i + " to player: " + controllerPlayerIDMapping[i], this, LogLevel.Log);
                    }
                }
                else
                {
                    if (MenuInput.GetStartKeyDown(gamepads[i]))
                    {
                        state = MenuState.LevelSelect;
                        Logger.Log("Players confirmed: " + GM.GameInstance.Players.Capacity, this, LogLevel.Log);
                    }
                    //pass on input
                }
            }
            break;

        case MenuState.LevelSelect:
            if (MenuInput.GetSelectKeyDown(gamepads))
            {
                Logger.Log("Loading DevLevel3.0", this, LogLevel.Log);
                SceneManager.LoadScene("DevLevel3.0");
                //Get current stage
                //load current stage
                return;
            }
            //Pass on input
            break;
        }
    }
Ejemplo n.º 23
0
 void Start()
 {
     ph = GetComponent<PlayerHealth>();
        ps = GetComponent<PlayerShooting>();
     //Y = 3.5f;
     rb = GetComponent<Rigidbody>();
     this.transform.position = new Vector3(X, Y, Z);
     counter = 0;
 }
Ejemplo n.º 24
0
 void Awake()
 {
     anim            = GetComponent <Animator> ();
     playerRigidbody = GetComponent <Rigidbody> ();
     playerShooting  = GetComponentInChildren <PlayerShooting> ();
 }
Ejemplo n.º 25
0
 void Awake()
 {
     //Get the StatsManager Script
     playerShooting = GetComponent <PlayerShooting> ();
 }
Ejemplo n.º 26
0
 public ShootCommand(PlayerShooting _playerShooting)
 {
     playerShooting = _playerShooting;
 }
Ejemplo n.º 27
0
 private void Awake()
 {
     playerShooting = GetComponent <PlayerShooting>();
 }
Ejemplo n.º 28
0
    void Start()
    {
        Screen.showCursor = false;
        timeElapsed = 0;

        coins = PlayerPrefsManager.GetCoins();
        blockWhenNoGazeData = PlayerPrefsManager.GetControl();
        GameObject.Find("Highscore").GetComponent<HighscoreScript>().UpdateCoins(coins);
        GameObject.Find("Highscore").GetComponent<HighscoreScript>().AddScoreValue(PlayerPrefsManager.GetScore());

        lifeControl = GameObject.FindGameObjectWithTag("MainGUI").GetComponent<SubmarineLifeControl>();
        movePlayer = GameObject.FindGameObjectWithTag("Player").GetComponent<MovePlayer>();
        shooting = GameObject.Find("gun").GetComponent<PlayerShooting>();
        powerUpSpawner = GameObject.Find("GameController").GetComponent<PowerUpSpawner>();
    }
Ejemplo n.º 29
0
 private void Awake()
 {
     _playerMovement = GetComponent <PlayerMovement> ();
     _playerShooting = GetComponentInChildren <PlayerShooting> ();
     CurrentHealth   = StartingHealth;
 }
Ejemplo n.º 30
0
 void Start()
 {
     _playerMovement = GetComponent <PlayerMovement>();
     _playerShooting = GetComponent <PlayerShooting>();
     _currentHealth  = StartingHealth;
 }
Ejemplo n.º 31
0
 private void Awake()
 {
     _charMovement   = GetComponent <PlayerMovement>();
     _playerShooting = GetComponent <PlayerShooting>();
 }
Ejemplo n.º 32
0
	void Awake () {
		//Get the StatsManager Script
		playerShooting = GetComponent<PlayerShooting> ();
	}
Ejemplo n.º 33
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Enemy"))
        {
            GameMaster.Instance.Freeze(freezeDuration);
            if (freezeDuration < .15f)
            {
                freezeDuration += addFreezeDuration;
            }

            if (ReadWriteSaveManager.Instance.GetData("CanFlash", true, false))
            {
                var flashInst = Instantiate(flashObj, other.transform.position, Quaternion.identity);
                Destroy(flashInst.gameObject, .25f);

                GameMaster.Instance.ChangeBackColor(colorNum);
                if (colorNum < .35f)
                {
                    colorNum += .05f;
                }
            }

            AudioManager.Instance.Play("EnemyHit", pitch);
            pitch += .05f;

            HomingEnemy   homingEnemy   = other.gameObject.GetComponent <HomingEnemy>();
            ShootingEnemy shootingEnemy = other.gameObject.GetComponent <ShootingEnemy>();
            SittingEnemy  sittingEnemy  = other.gameObject.GetComponent <SittingEnemy>();
            DashingEnemy  dashingEnemy  = other.gameObject.GetComponent <DashingEnemy>();

            if (homingEnemy)
            {
                scoreText.SetScore(addScoreHomingHit + addScoreStacking);
                comboUI.SetCounter(addScoreHomingHit + addScoreStacking, homingEnemy.transform.position);
                homingEnemy.DamageEnemy();
                defeatedHoming = true;
            }
            else if (shootingEnemy)
            {
                scoreText.SetScore(addScoreShootingHit + addScoreStacking);
                comboUI.SetCounter(addScoreShootingHit + addScoreStacking, shootingEnemy.transform.position);
                shootingEnemy.DamageEnemy();
                defeatedShooting = true;
            }
            else if (sittingEnemy)
            {
                scoreText.SetScore(addScoreSittingHit + addScoreStacking);
                comboUI.SetCounter(addScoreSittingHit + addScoreStacking, sittingEnemy.transform.position);
                sittingEnemy.DamageEnemy();
                defeatedSitting = true;
            }
            else if (dashingEnemy)
            {
                int dashingAdd = dashingEnemy.GetAddScore();
                scoreText.SetScore(addScoreDashingHit + addScoreStacking + dashingAdd);
                comboUI.SetCounter(addScoreDashingHit + addScoreStacking + dashingAdd, dashingEnemy.transform.position);
                dashingEnemy.DamageEnemy();
                defeatedDashing = true;
            }

            addScoreStacking += 100;
            comboCounter++;
            GameMaster.Instance.SpongeCheckUnlock(comboCounter);
            GameMaster.Instance.BounceCheckUnlock(defeatedHoming, defeatedShooting, defeatedSitting, defeatedDashing);
            GameMaster.Instance.HomingCheck(comboCounter);
        }

        if (other.CompareTag("Player"))
        {
            PlayerShooting playerShooting = other.GetComponent <PlayerShooting>();

            if (playerShooting.isRecalling || playerShooting.canRecall)
            {
                shake.Shake(shakeDuration, shakeIntensity);
                AudioManager.Instance.Play("PlayerTriHit");
                playerShooting.BulletHit();
                Destroy(parentBul.gameObject);
            }
        }
    }
Ejemplo n.º 34
0
    // Update is called once per frame
    void Update()
    {
        anim_current_paw = current_cat_paw.GetComponent <Animator> ();
        //Change to cat_paw_toast
        if (tScript.changeToToast)
        {
            if (!main_changed)
            {
                Debug.Log("to_toast");
                changePawToToast();
                is_toast = true;
                is_main  = false;
            }
            tScript.changeToToast = false;
        }
        else if (shootingScript.changeToMain)
        {
            if (!toast_changed)
            {
//				Debug.Log("to_main");
                changePawToMain();
                is_toast = false;
                is_main  = true;
            }
            shootingScript.changeToMain = false;
        }


        if ((to_toast) && (paw_main_animator.GetCurrentAnimatorStateInfo(0).IsName("paw_down_done")))
        {
            //Disable current paw's components
            GameObject cat_paw_mesh = GameObject.Find("cat_paw_mesh");
            mesh         = cat_paw_mesh.GetComponent <MeshRenderer>();
            mesh.enabled = false;

            cat_anim = paw_main.GetComponent <Animator>();
            //cat_anim.SetTrigger("reset");
            cat_anim.enabled = false;
            Debug.Log("anim = false");

            cat_box_collider         = paw_main.GetComponent <BoxCollider>();
            cat_box_collider.enabled = false;

            cat_playerSwipe         = paw_main.GetComponent <PlayerSwipe>();
            cat_playerSwipe.enabled = false;

            main_changed = false;
            to_toast     = false;
        }

        if ((to_main) && (paw_toast_animator.GetCurrentAnimatorStateInfo(0).IsName("paw_down_toast_done")))
        {
            //Disable current paw's components
            GameObject cat_paw_toast_mesh = GameObject.Find("cat_paw_toast_mesh");
            mesh         = cat_paw_toast_mesh.GetComponent <MeshRenderer>();
            mesh.enabled = false;

            cat_anim = paw_toast.GetComponent <Animator>();
            //cat_anim.SetTrigger("reset");
            cat_anim.enabled = false;

            cat_playerSwipe         = paw_toast.GetComponent <PlayerSwipe>();
            cat_playerSwipe.enabled = false;

            GameObject     main_camera  = GameObject.Find("Main Camera");
            PlayerShooting cat_shooting = main_camera.GetComponent <PlayerShooting> ();
            cat_shooting.enabled = false;

            toast_changed = false;
            to_main       = false;
        }
    }
Ejemplo n.º 35
0
    //float clicked;

    void Awake()
    {
        _agent         = GetComponent <NavMeshAgent>();
        _animator      = GetComponent <Animator>();
        playershooting = GetComponentInChildren <PlayerShooting> ();
    }
Ejemplo n.º 36
0
 // Start is called before the first frame update
 void Start()
 {
     ammo = FindObjectOfType <PlayerShooting>();
 }
Ejemplo n.º 37
0
 private void Awake()
 {
     playerShooting = GetComponent <PlayerShooting>();
     playerShooting.WeaponChanged += UpdateGUI;
 }
Ejemplo n.º 38
0
    void Start()
    {
        //weaponAudio = GetComponent<AudioSource>();
        playerShootingGod = GetComponentInParent<PlayerShooting>();

        colorIndex = PlayerPrefs.GetInt("crosshairColor");
        crosshairColor = xhairColors[colorIndex];

        SetInitialSpeed();
        SetInitialCrosshair();
        SetInitialAmmo();
    }
Ejemplo n.º 39
0
 void Awake()
 {
     PlayerShooting = GetComponent <PlayerShooting> ();
 }
Ejemplo n.º 40
0
	void OnTriggerEnter(Collider other) {

		//Check if it is the player
		if (other.tag == "Player") {
			playerStats = other.GetComponent<StatsManager> ();
			playerShooting = other.GetComponent<PlayerShooting> ();
			playerMovement = other.GetComponent<PlayerMovement> ();
			playerPrefix = other.name;
			playerAugSprite = GameObject.Find (playerPrefix + "Aug");
			playerWeapSprite = GameObject.Find (playerPrefix + "Weap");
			if (other.name == "P1") {
				nextPickup = nextPickupP1;
			} else {
				nextPickup = nextPickupP2;
			}

			if (Time.time > nextPickup) {

				//Check which pickup it is and apply effects
				switch (powerupType) 
				{
				// case "BeepAugment":
				// 	Augment temp = new Augment ("Sounds/beep/beep_1");
				// 	Debug.Log (temp);
				// 	playerStats.SetAugment (temp);
				// 	playerAugSprite.GetComponent<Image> ().sprite = Resources.Load<Sprite> ("SpeedUpSprite");

				// 	Debug.Log (playerStats.GetAugment());

				// 	break;
				// case "GrowAugment":
				// 	GrowAugment g = new GrowAugment();
				// 	Debug.Log (g);
				// 	playerStats.SetAugment (g);
				// 	playerAugSprite.GetComponent<Image> ().sprite = Resources.Load<Sprite> ("BulletSpeedUpSprite");

				// 	Debug.Log (playerStats.GetAugment());

				// 	break;
				case "FireAugment":
					if (playerStats.GetAugment() != null) {
						oldAugment = playerStats.GetAugment().Element;
					}
					FireAugment f = new FireAugment();
					Debug.Log (f);
					playerStats.SetAugment (f);
					playerAugSprite.GetComponent<Image> ().sprite = Resources.Load<Sprite> ("Interface/Augment-Red-Blank");
					audioPlacement.PlayClip("AugmentPickUp", 1f);

					Debug.Log (playerStats.GetAugment());

					break;
				case "IceAugment":
					if (playerStats.GetAugment() != null) {
						oldAugment = playerStats.GetAugment().Element;
					}
					IceAugment i = new IceAugment();
					Debug.Log (i);
					playerStats.SetAugment (i);
					playerAugSprite.GetComponent<Image> ().sprite = Resources.Load<Sprite> ("Interface/Augment-Blue-Blank");
					audioPlacement.PlayClip("AugmentPickUp", 1f);

					Debug.Log (playerStats.GetAugment());

					break;
				case "EarthAugment":
					if (playerStats.GetAugment() != null) {
						oldAugment = playerStats.GetAugment().Element;
					}
					EarthAugment e = new EarthAugment ();
					Debug.Log (e);
					playerStats.SetAugment (e);
					playerAugSprite.GetComponent<Image> ().sprite = Resources.Load<Sprite> ("Interface/Augment-Green-Blank");
					audioPlacement.PlayClip("AugmentPickUp", 1f);

					Debug.Log (playerStats.GetAugment ());

					break;

				case "Pistol":
					oldWeapon = playerShooting.curWeap;
					playerShooting.ChangeWeapon(powerupType);
					audioPlacement.PlayClip("WeaponPickUp", 1f);
					break;

				case "RayGun":
					oldWeapon = playerShooting.curWeap;
					playerShooting.ChangeWeapon(powerupType);
					//playerWeapSprite.GetComponent<Image> ().sprite = Resources.Load<Sprite> ("raygunsprite");
					audioPlacement.PlayClip("WeaponPickUp", 1f);
					break;

				case "Sword":
					oldWeapon = playerShooting.curWeap;
					playerShooting.ChangeWeapon (powerupType);
					//playerWeapSprite.GetComponent<Image> ().sprite = Resources.Load<Sprite> ("swordsprite");
					audioPlacement.PlayClip("WeaponPickUp", 1f);
					break;

				case "FullHealth":
					if (HealthManager.currentHealth < 10) {
						HealthManager.HealHealth (2);
						audioPlacement.PlayClip("ItemPickUp", 1f);
					} else {
						notUsed = true;
					}
					break;
				
				case "HalfHealth":
					if (HealthManager.currentHealth < 10) {
						HealthManager.HealHealth (1);
						audioPlacement.PlayClip("ItemPickUp", 1f);
					} else {
						notUsed = true;
					}
					break;
				}

				if (oldWeapon != null) {
					if (oldWeapon == "Pistol") {
						oldWeaponPickup = Instantiate (pistolPickup, transform.position, pistolPickup.transform.rotation) as GameObject;
					} else if (oldWeapon == "RayGun") {
						oldWeaponPickup = Instantiate (rayGunPickup, transform.position, rayGunPickup.transform.rotation) as GameObject;
					} else if (oldWeapon == "Sword") {
						oldWeaponPickup = Instantiate (swordPickup, transform.position, swordPickup.transform.rotation) as GameObject;
					}

					oldWeaponPickup.transform.parent = playerStats.RoomIn.transform;
					oldWeapon = null;
				}

				if (oldAugment != null) {
					if (oldAugment == "fire") {
						oldAugmentPickup = Instantiate (redAugmentPickup, transform.position, redAugmentPickup.transform.rotation) as GameObject;
					} else if (oldAugment == "ice") {
						oldAugmentPickup = Instantiate (blueAugmentPickup, transform.position, blueAugmentPickup.transform.rotation) as GameObject;
					} else if (oldAugment == "earth") {
						oldAugmentPickup = Instantiate (greenAugmentPickup, transform.position, greenAugmentPickup.transform.rotation) as GameObject;
					}

					oldAugmentPickup.transform.parent = playerStats.RoomIn.transform;
					oldAugment = null;
				}

				//Get rid of the pickup if it has been used
				if (!notUsed){
					Destroy (gameObject);
				}
				
				//Reset the variable for next switch statement
				notUsed = false;

				//Check if P1 or P2 picked it up, update nextPickup time respectively
				if (other.name == "P1") {
					nextPickupP1 = Time.time + 1f;
				} else {
					nextPickupP2 = Time.time + 1f;
				}
			}
		}
	}
Ejemplo n.º 41
0
 static public void SetPlayerShooting(PlayerShooting ps)
 {
     playerShooting = ps;
 }
Ejemplo n.º 42
0
    void Start()
    {
        playerShooting = GetComponent <PlayerShooting> ();

        lengthReloadSound = reloadSound.length;
    }
Ejemplo n.º 43
0
	//AudioSource audio;
	// Use this for initialization
	void Start () {

		PhotonNetwork.sendRate = 30;
		PhotonNetwork.sendRateOnSerialize = 15;
        currentWeaponIndex = 0;
		alive = true; 
		photonView = GetComponent<PhotonView> ();
		//Disables my Character Controller interstingly enough. That way I can only enable it for the clien'ts player.  
		transform.GetComponent<Collider>().enabled = false;
		//Use this to get current player this script is attached too
		aSources = GetComponents<AudioSource> (); 
		audio0 = aSources [0];
		audio1 = aSources [1];
		audio2 = aSources [2];
        lerpRate = normalLerpRate;
		anim = GetComponentInChildren<Animator> ();
		//animEthan = transform.Find("char_ethan").GetComponent<Animator> ();
		injuryAnim = GameObject.FindGameObjectWithTag ("InjuryEffect").GetComponent<Animator>();
		GMan = GameObject.FindGameObjectWithTag("GameManager").GetComponent<GameManager>();
		NM = GameObject.FindGameObjectWithTag ("NetworkManager").GetComponent<NetworkManager>();
		playerShooting = GetComponentInChildren<PlayerShooting> ();

		/*muzzleLightFlashGO = GameObject.FindGameObjectsWithTag("LightFlash");
		
		//To assign the each players own muzzle flash toggle and not someone elses. 
		for(int i = 0; i < muzzleLightFlashGO.Length; i++){
			//If the weapon we find has the same ID as the player its attached to, set the tag to layer 10
			if(muzzleLightFlashGO[i].GetComponentInParent<PlayerShooting>().gameObject.GetInstanceID() == playerShooting.gameObject.GetInstanceID() ){
				muzzleLightFlash = muzzleLightFlashGO[i].GetComponent<Light>();
				//muzzleLightFlash.enabled = false;
				//muzzleFlashToggle = false;
				
			}
		}*/
		//If its my player, not anothers
		Debug.Log ("<color=red>Joined Room </color>" + PhotonNetwork.player.name + " " + photonView.isMine);
		if (photonView.isMine) {
            
			//Enable CC so we can control character. 
			transform.GetComponent<Collider>().enabled = true;
			//Use for Sound toggle
			_characterController = GetComponent<CharacterController>();
	
			playerName = PhotonNetwork.player.name;
			//enable each script just for the player being spawned and not the others
			GetComponent<Rigidbody>().useGravity = true; 
			GetComponent<UnitySampleAssets.Characters.FirstPerson.FirstPersonController>().enabled = true;
			playerShooting.enabled = true;
			foreach(Camera cam in GetComponentsInChildren<Camera>()){
				cam.enabled = true; 
			}
			foreach(AudioListener AL in GetComponentsInChildren<AudioListener>()){
				AL.enabled = true; 
			}

			//So that we can see our own weapons on the second camera and not other player weapons through walls
            WeaponSetup();
     
			//Change Body Part Collider Layers from default to body just for the player's own game not all players so that they can collide with others
			//We need to ignore colliders cause we layer a lot of them together
			//So we find all body parts and if it matches our own we are good to change it so it can be ignored.
			for(int i = 0; i < GameObject.FindGameObjectsWithTag("Body").Length; i++){

				if(GameObject.FindGameObjectsWithTag("Body")[i].GetComponentInParent<PlayerNetworkMover>().gameObject.GetInstanceID() == gameObject.GetInstanceID() ){
					GameObject.FindGameObjectsWithTag("Body")[i].layer = 12;
				}
			}
			//Now for the head
			for(int i = 0; i < GameObject.FindGameObjectsWithTag("Head").Length; i++){
				
				if(GameObject.FindGameObjectsWithTag("Head")[i].GetComponentInParent<PlayerNetworkMover>().gameObject.GetInstanceID() == gameObject.GetInstanceID() ){
					GameObject.FindGameObjectsWithTag("Head")[i].layer = 12;
				}
			}
			//If player is ours have CC ignore body parts
			Physics.IgnoreLayerCollision(0,12, true);
            InitPostProcessingEffects();
		}
		else{
            //All other players
			StartCoroutine ("UpdateData");
		}
		/*if(muzzleLightFlash != null){
			muzzleFlashToggle = true;
			if(muzzleFlashToggle){
				Debug.Log ("muzzleFlash True");
				muzzleLightFlash.enabled = true;
			}
			else{
				muzzleLightFlash.enabled = false;
			}
		}*/
	}
Ejemplo n.º 44
0
 void Awake()
 {
     _plShoot = GetComponent <PlayerShooting>();
 }
Ejemplo n.º 45
0
    void Awake()
    {
        testText = GameObject.Find("TestText");
        test     = testText.GetComponent <Text> ();

        player   = GameObject.FindGameObjectWithTag("Player");
        kretanje = player.GetComponent <PlayerMovement> ();
        pHP      = player.GetComponent <PlayerHealth> ();
        pEN      = player.GetComponent <PlayerEnergy> ();
//		Center = GameObject.Find ("Center");
//		Front = GameObject.Find ("Front");
//		Back = GameObject.Find ("Back");
        LeftWing         = GameObject.Find("LeftWing");
        RightWing        = GameObject.Find("RightWing");
        lW               = LeftWing.GetComponent <PlayerShooting> ();
        rW               = RightWing.GetComponent <PlayerShooting> ();
        lWLR             = LeftWing.GetComponent <LineRenderer> ();
        rWLR             = RightWing.GetComponent <LineRenderer> ();
        lWParticles      = LeftWing.GetComponent <ParticleSystem> ();
        rWParticles      = RightWing.GetComponent <ParticleSystem> ();
        klasaTekstObjekt = GameObject.Find("ClassNameText");
        klasaTekst       = klasaTekstObjekt.GetComponent <Text> ();
        abilityImageHUD1 = GameObject.FindGameObjectWithTag("Ability1");
        abilityImage1    = abilityImageHUD1.GetComponent <Image> ();
        abilityImageHUD2 = GameObject.FindGameObjectWithTag("Ability2");
        abilityImage2    = abilityImageHUD2.GetComponent <Image> ();
        abilityImageHUD3 = GameObject.FindGameObjectWithTag("Ability3");
        abilityImage3    = abilityImageHUD3.GetComponent <Image> ();

        direktorij = Directory.GetCurrentDirectory();

        provjera  = direktorij + @"\radioaktivne_mrkve.txt";
        provjera2 = direktorij + @"\radioaktivne_mrkve2.txt";

        if (!File.Exists(provjera))
        {
            klasa = 1;
        }
        else
        {
            System.IO.StreamReader file = new System.IO.StreamReader(provjera);
            while ((line = file.ReadLine()) != null)
            {
                if (line.Contains("Klasa: "))
                {
                    spremanje = line;
                    spremanje = spremanje.Replace("Klasa: ", "");
                }
            }
            file.Close();
            klasa = int.Parse(spremanje);
            if (klasa < 1 || klasa > 5)
            {
                klasa = 1;
            }
            file.Close();
            System.IO.StreamReader file2 = new System.IO.StreamReader(provjera);
            while ((line = file2.ReadLine()) != null)
            {
                provjera_load = klasa.ToString() + "Level: ";
                if (line.Contains(provjera_load))
                {
                    spremanje = line;
                    spremanje = spremanje.Replace(provjera_load, "");
                    level     = int.Parse(spremanje);
                }
                provjera_load = klasa.ToString() + "Experience: ";
                if (line.Contains(provjera_load))
                {
                    spremanje  = line;
                    spremanje  = spremanje.Replace(provjera_load, "");
                    experience = int.Parse(spremanje);
                }

                provjera_load = klasa.ToString() + "hpUp: ";
                if (line.Contains(provjera_load))
                {
                    spremanje = line;
                    spremanje = spremanje.Replace(provjera_load, "");
                    tempHP    = int.Parse(spremanje);
                }
                provjera_load = klasa.ToString() + "pdUp: ";
                if (line.Contains(provjera_load))
                {
                    spremanje = line;
                    spremanje = spremanje.Replace(provjera_load, "");
                    tempPDMG  = float.Parse(spremanje);
                }
                provjera_load = klasa.ToString() + "sdUp: ";
                if (line.Contains(provjera_load))
                {
                    spremanje = line;
                    spremanje = spremanje.Replace(provjera_load, "");
                    tempSDMG  = float.Parse(spremanje);
                }
                provjera_load = klasa.ToString() + "enUp: ";
                if (line.Contains(provjera_load))
                {
                    spremanje = line;
                    spremanje = spremanje.Replace(provjera_load, "");
                    tempEN    = float.Parse(spremanje);
                }
                provjera_load = klasa.ToString() + "regUp: ";
                if (line.Contains(provjera_load))
                {
                    spremanje = line;
                    spremanje = spremanje.Replace(provjera_load, "");
                    tempREG   = float.Parse(spremanje);
                }
                provjera_load = klasa.ToString() + "movUp: ";
                if (line.Contains(provjera_load))
                {
                    spremanje = line;
                    spremanje = spremanje.Replace(provjera_load, "");
                    tempMov   = float.Parse(spremanje);
                }
            }
            file2.Close();
        }

        if (klasa == 1)
        {
            className   = "Aurelius ";
            fireEffect1 = 1;
            fireEffect2 = 2;

            Sprite newSprite = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Elements_Nature");
            if (newSprite)
            {
                abilityImage1.sprite = newSprite;
            }
            //Heal healComp = Center.AddComponent<Heal>() as Heal;
        }
        if (klasa == 2)
        {
            className   = "Bismarck ";
            fireEffect1 = 0;
            fireEffect2 = 3;

            MeshRenderer mesh = player.GetComponent <MeshRenderer> ();
            mesh.material = Resources.Load <Material>("Meshes/SciFi_Fighter_AK5-diffuse-Yellow");

            Sprite newSprite = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Weapons_Bow");
            if (newSprite)
            {
                abilityImage1.sprite = newSprite;
            }
            Front = (GameObject)Instantiate(Resources.Load("Parts/FrontBismarck"));
            Front.transform.parent = player.transform;

            Sprite newSprite2 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Weapons_Hammer");
            if (newSprite2)
            {
                abilityImage2.sprite = newSprite2;
            }
            Center = (GameObject)Instantiate(Resources.Load("Parts/CenterBismarck"));
            Center.transform.parent = player.transform;

            Sprite newSprite3 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Equipment_Shield");
            if (newSprite3)
            {
                abilityImage3.sprite = newSprite3;
            }
            Back = (GameObject)Instantiate(Resources.Load("Parts/BackBismarck"));
            Back.transform.parent = player.transform;
        }
        if (klasa == 3)
        {
            className   = "Themistocles ";
            fireEffect1 = 0;
            fireEffect2 = 2;

            Sprite newSprite3 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Weapons_Bomb");
            if (newSprite3)
            {
                abilityImage3.sprite = newSprite3;
            }
            Front = (GameObject)Instantiate(Resources.Load("Parts/FrontThemistocles"));
            Front.transform.parent = player.transform;

            Sprite newSprite2 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Modifiers_Time");
            if (newSprite2)
            {
                abilityImage2.sprite = newSprite2;
            }
            Center = (GameObject)Instantiate(Resources.Load("Parts/CenterThemistocles"));
            Center.transform.parent = player.transform;

            Sprite newSprite1 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Equipment_Boots");
            if (newSprite1)
            {
                abilityImage1.sprite = newSprite1;
            }
            Back = (GameObject)Instantiate(Resources.Load("Parts/BackThemistocles"));
            Back.transform.parent = player.transform;
        }
        if (klasa == 4)
        {
            className   = "Tesla ";
            fireEffect1 = 0;
            fireEffect2 = 5;

            MeshRenderer mesh = player.GetComponent <MeshRenderer> ();
            mesh.material = Resources.Load <Material>("Meshes/SciFi_Fighter_AK5-diffuse-Blue");

            rWParticles.startColor = Color.blue;
            lWParticles.startColor = Color.blue;

            Sprite newSprite1 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Modifiers_Accuracy");
            if (newSprite1)
            {
                abilityImage1.sprite = newSprite1;
            }
            Center = (GameObject)Instantiate(Resources.Load("Parts/BackTesla"));
            Center.transform.parent = player.transform;

            Sprite newSprite2 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Elements_Air");
            if (newSprite2)
            {
                abilityImage2.sprite = newSprite2;
            }
            Center = (GameObject)Instantiate(Resources.Load("Parts/CenterTesla"));
            Center.transform.parent = player.transform;

            Sprite newSprite3 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Modifiers_LevelUp");
            if (newSprite3)
            {
                abilityImage3.sprite = newSprite3;
            }
            Center = (GameObject)Instantiate(Resources.Load("Parts/FrontTesla"));
            Center.transform.parent = player.transform;
        }
        if (klasa == 5)
        {
            className   = "Archimedes ";
            fireEffect1 = 0;
            fireEffect2 = 4;

            Sprite newSprite1 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Elements_Fire");
            if (newSprite1)
            {
                abilityImage1.sprite = newSprite1;
            }
            Front = (GameObject)Instantiate(Resources.Load("Parts/FrontArchimedes"));
            Front.transform.parent = player.transform;

            Sprite newSprite2 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/World_RoseOfWinds");
            if (newSprite2)
            {
                abilityImage2.sprite = newSprite2;
            }
            Back = (GameObject)Instantiate(Resources.Load("Parts/BackArchimedes"));
            Back.transform.parent = player.transform;

            Sprite newSprite3 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/UI_Gamepad");
            if (newSprite3)
            {
                abilityImage3.sprite = newSprite3;
            }
            Center = (GameObject)Instantiate(Resources.Load("Parts/CenterArchimedes"));
            Center.transform.parent = player.transform;
            //Drones dronesComp = Center.AddComponent<Drones>();
        }
        tempStr         = className + level.ToString();
        klasaTekst.text = tempStr;

        expSlider.value = experience;

        rHealth   = classData.RetrieveInteger(1, klasa);
        rHealth   = rHealth + tempHP;
        rEnergy   = classData.RetrieveFloat(1, klasa);
        rEnergy   = rEnergy + tempEN;
        rRegen    = classData.RetrieveFloat(2, klasa);
        rRegen    = rRegen + tempREG;
        rMovement = classData.RetrieveFloat(3, klasa);
        rMovement = rMovement + tempMov;
        rPROF     = classData.RetrieveFloat(4, klasa);

        rSROF = classData.RetrieveFloat(5, klasa);

        rPDMG = classData.RetrieveFloat(6, klasa);
        rPDMG = rPDMG + tempPDMG;
        rSDMG = classData.RetrieveFloat(7, klasa);
        rSDMG = rSDMG + tempSDMG;

        float tempDelay1, tempDelay2;

        tempDelay1 = 0.2f / (rPROF / 0.15f);
        tempDelay2 = 0.2f / (rSROF / 0.15f);

        pHP.SetHealth(rHealth);
        pEN.SetEnergy(rEnergy, rRegen);
        kretanje.SetSpeed(rMovement);
        lW.SetData(rPDMG, rPROF, 80f, "Fire1", tempDelay1, fireEffect1);
        rW.SetData(rSDMG, rSROF, 80f, "Fire2", tempDelay2, fireEffect2);

        string tempLineRender = "LineRenderMaterial" + klasa.ToString();

        lWLR.material = Resources.Load <Material>(tempLineRender);
        rWLR.material = Resources.Load <Material>(tempLineRender);
    }
Ejemplo n.º 46
0
 void Start()
 {
     time = GetComponent<Timeline>();
     _Anim = GetComponent<Animator>();
     _Rb2d = time.GetComponent<Rigidbody2D>();
     _PlayerShooting = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerShooting>();
 }
Ejemplo n.º 47
0
 void Start()
 {
     shake  = Camera.main.GetComponent <ScreenShake>();
     player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerShooting>();
 }
Ejemplo n.º 48
0
	// Use this for initialization
	void Start () {
		playerAugment = null;

		if (playerPrefix == "P1") {
			otherPlayerPrefix = "P2";
		} else {
			otherPlayerPrefix = "P1";
		}

		if ((Application.platform == RuntimePlatform.OSXEditor) || (Application.platform == RuntimePlatform.OSXPlayer)) {
			swapButtonAug = "SwapAugMac" + playerPrefix;
		} else if ((Application.platform == RuntimePlatform.WindowsEditor) || (Application.platform == RuntimePlatform.WindowsPlayer)) {
			swapButtonAug = "SwapAugPC" + playerPrefix;
		}

		otherPlayerStats = GameObject.Find (otherPlayerPrefix).GetComponent<StatsManager> ();
		playerAugSprite = GameObject.Find (playerPrefix + "Aug");
		otherPlayerAugSprite = GameObject.Find (otherPlayerPrefix + "Aug");
		otherPlayerHudImage = GameObject.Find(otherPlayerPrefix + "Hud").GetComponent<Image>();
		if (playerPrefix == "P1") {
			hudDefault = Resources.Load<Sprite> ("Interface/P2-slots-blank");
			hudReq = Resources.Load<Sprite> ("Interface/P2-slots-prompt");
		} else if (playerPrefix == "P2") {
			hudDefault = Resources.Load<Sprite> ("Interface/P1-slots-blank");
			hudReq = Resources.Load<Sprite> ("Interface/P1-slots-prompt");
		}

		if (roomIn != null) {
			transform.position = new Vector3(roomIn.transform.position.x, 0f, roomIn.transform.position.z);
		}

		playerShooting = GetComponent<PlayerShooting> ();
		otherPlayerShooting = GameObject.Find (otherPlayerPrefix).GetComponent<PlayerShooting> ();

		foreach (Transform child in transform) {
			if (child.tag == "Hoop") {
				hoopController = child.gameObject.GetComponent<HoopController>();
			}
		}
		//Determine shooting buttons for OS and Player
		if ((Application.platform == RuntimePlatform.OSXEditor) || (Application.platform == RuntimePlatform.OSXPlayer)) {
			pingButton = "PingMac" + playerPrefix;
		} else if ((Application.platform == RuntimePlatform.WindowsEditor) || (Application.platform == RuntimePlatform.WindowsPlayer)) {
			pingButton = "PingPC" + playerPrefix;
		}

	}
Ejemplo n.º 49
0
 void Awake()
 {
     playerMovement = GetComponent <PlayerController>();
     playerShooting = GetComponentInChildren <PlayerShooting>();
     currentHealth  = startingHealth;
 }
Ejemplo n.º 50
0
    public override void Shoot(float timer, PlayerShooting shootingControl)
    {
        if (timer >= timeBetweenBullets && Time.timeScale != 0 && !playerHealth.dead && !playerHealth.end)
        {
            shootingControl.ResetTimer();
            effectTimer = 0f;
            // Play the gun shot audioclip.
            gunAudio.Play();

            // Enable the lights.
            gunLight.enabled  = true;
            faceLight.enabled = true;

            // Stop the particles from playing if they were, then start the particles.
            gunParticles.Stop();
            gunParticles.Play();

            // Enable the line renderer and set it's first position to be the end of the gun.
            gunLine1.enabled = true;
            gunLine1.SetPosition(0, transform.position);

            // Enable the line renderer and set it's first position to be the end of the gun.
            gunLine2.enabled = true;
            gunLine2.SetPosition(0, transform.position);

            // Enable the line renderer and set it's first position to be the end of the gun.
            gunLine3.enabled = true;
            gunLine3.SetPosition(0, transform.position);

            Ray        shootRay1 = new Ray();                // A ray from the gun end forwards.
            Ray        shootRay2 = new Ray();                // A ray from the gun end forwards.
            Ray        shootRay3 = new Ray();                // A ray from the gun end forwards.
            RaycastHit shootHit1;                            // A raycast hit to get information about what was hit.
            RaycastHit shootHit2;                            // A raycast hit to get information about what was hit.
            RaycastHit shootHit3;                            // A raycast hit to get information about what was hit.

            // Set the shootRay so that it starts at the end of the gun and points forward from the barrel.
            shootRay1.origin    = transform.position;
            shootRay1.direction = transform.forward;


            // Set the shootRay so that it starts at the end of the gun and points forward from the barrel.
            shootRay2.origin    = transform.position;
            shootRay2.direction = Quaternion.Euler(0, -15, 0) * transform.forward;


            // Set the shootRay so that it starts at the end of the gun and points forward from the barrel.
            shootRay3.origin    = transform.position;
            shootRay3.direction = Quaternion.Euler(0, 15, 0) * transform.forward;

            // Perform the raycast against gameobjects on the shootable layer and if it hits something...
            if (Physics.Raycast(shootRay1, out shootHit1, range, shootableMask))
            {
                // Try and find an EnemyHealth script on the gameobject hit.
                EnemyHealth enemyHealth = shootHit1.collider.GetComponent <EnemyHealth>();

                // If the EnemyHealth component exist...
                if (enemyHealth != null)
                {
                    // ... the enemy should take damage.
                    enemyHealth.TakeDamage(damagePerShot, shootHit1.point);
                }

                // Set the second position of the line renderer to the point the raycast hit.
                gunLine1.SetPosition(1, shootHit1.point);
            }
            // If the raycast didn't hit anything on the shootable layer...
            else
            {
                // ... set the second position of the line renderer to the fullest extent of the gun's range.
                gunLine1.SetPosition(1, shootRay1.origin + shootRay1.direction * range);
            }


            // Perform the raycast against gameobjects on the shootable layer and if it hits something...
            if (Physics.Raycast(shootRay2, out shootHit2, range, shootableMask))
            {
                // Try and find an EnemyHealth script on the gameobject hit.
                EnemyHealth enemyHealth = shootHit2.collider.GetComponent <EnemyHealth>();

                // If the EnemyHealth component exist...
                if (enemyHealth != null)
                {
                    // ... the enemy should take damage.
                    enemyHealth.TakeDamage(damagePerShot, shootHit2.point);
                }

                // Set the second position of the line renderer to the point the raycast hit.
                gunLine2.SetPosition(1, shootHit2.point);
            }
            // If the raycast didn't hit anything on the shootable layer...
            else
            {
                // ... set the second position of the line renderer to the fullest extent of the gun's range.
                gunLine2.SetPosition(1, shootRay2.origin + shootRay2.direction * range);
            }

            // Perform the raycast against gameobjects on the shootable layer and if it hits something...
            if (Physics.Raycast(shootRay3, out shootHit3, range, shootableMask))
            {
                // Try and find an EnemyHealth script on the gameobject hit.
                EnemyHealth enemyHealth = shootHit3.collider.GetComponent <EnemyHealth>();

                // If the EnemyHealth component exist...
                if (enemyHealth != null)
                {
                    // ... the enemy should take damage.
                    enemyHealth.TakeDamage(damagePerShot, shootHit3.point);
                }

                // Set the second position of the line renderer to the point the raycast hit.
                gunLine3.SetPosition(1, shootHit3.point);
            }
            // If the raycast didn't hit anything on the shootable layer...
            else
            {
                // ... set the second position of the line renderer to the fullest extent of the gun's range.
                gunLine3.SetPosition(1, shootRay3.origin + shootRay3.direction * range);
            }

            ammoCount = ammoCount - 3;
            if (ammoCount <= 0)
            {
                shootingControl.Switch(shootingControl.gun);
            }
        }
    }
Ejemplo n.º 51
0
 void Start()
 {
     player = GameObject.FindGameObjectWithTag("Player");
     gun = GameObject.FindGameObjectWithTag("Gun");
     playerHealth = player.GetComponent<PlayerHealth>();
     playerMovement = player.GetComponent<PlayerMovement>();
     playerShooting = gun.GetComponent<PlayerShooting>();
     inventory = GameObject.FindGameObjectWithTag ("Inventory").GetComponent<Inventory> ();
     itemImage = gameObject.transform.GetChild(0).GetComponent<Image> ();
     itemAmount = gameObject.transform.GetChild (1).GetComponent<Text> ();
 }