Ejemplo n.º 1
0
    public void SwapAugments()
    {
        hudReset = false;
        if (!swapLock)
        {
            swapLock = true;

            otherPlayerStats.RequestAugSwap = false;
            otherPlayerStats.DestroySwapPrompt();
            requestAugSwap = false;
            DestroySwapPrompt();

            tempAug = GetAugment();
            tempSpr = playerAugSprite.GetComponent <Image> ().sprite;

            SetAugment(otherPlayerStats.GetAugment());
            playerAugSprite.GetComponent <Image>().sprite = otherPlayerAugSprite.GetComponent <Image>().sprite;

            otherPlayerStats.SetAugment(tempAug);
            otherPlayerAugSprite.GetComponent <Image>().sprite = tempSpr;

            swapLock = false;
        }
        nextAugSwap    = Time.time + 4;
        swapAugTimeout = 0;
    }
Ejemplo n.º 2
0
 public void SetAugment(iAugment augment)
 {
     playerAugment = augment;
     if (augment == null)
     {
         augmentName = "No Augment";
     }
     else
     {
         augmentName = augment.Element;
     }
 }
Ejemplo n.º 3
0
	void Shoot (Vector3 shootDir) {
		shakeCamera.GetComponent<CameraShaker> ().shake = 0.1f;
		AudioSource.PlayClipAtPoint (shootSound, transform.position);

		aug = GetComponent<StatsManager> ().GetAugment ();
		weaponType = playerStats.weaponType;

		switch (weaponType) {

		case "Pistol":
			baseBulletSpeed = 10f;
			baseFireRate = 0.5f;
			cur_bullet = Reg_bullet;
			break;

		case "RayGun":
			baseBulletSpeed = 20f;
			baseFireRate = 0.000000001f;
			cur_bullet = RayGun_bullet;
			break;
		}
		//Create the bullet and launch it
		GameObject clone = Instantiate (cur_bullet, new Vector3(transform.position.x, transform.position.y + 0.5f, transform.position.z), transform.rotation) as GameObject;
		clone.transform.rotation = Quaternion.LookRotation (shootDir);
		Physics.IgnoreCollision (clone.GetComponent<Collider> (), GetComponent<Collider> ());
		clone.GetComponent<Rigidbody> ().velocity = (clone.transform.forward * ((baseBulletSpeed + bulletSpeedModifier)));

		Debug.Log ("Firing augged bullet");

		if (aug != null) {
			Debug.Log ("Applying on-hit effects");
			clone.GetComponent<BulletBehavior> ().setAugment(aug);
			GameObject augEffect;
			if (aug.Element == "fire") {
				Debug.Log ("Applying fire effects");
				augEffect = Instantiate (fireEffect, clone.transform.position, Quaternion.identity) as GameObject;
				augEffect.transform.parent = clone.transform;
			}else if (aug.Element == "ice") {
				Debug.Log ("Applying ice effects");
				augEffect = Instantiate (iceEffect, clone.transform.position, Quaternion.identity) as GameObject;
				augEffect.transform.parent = clone.transform;
			}else if (aug.Element == "earth") {
				Debug.Log ("Applying earth effects");
				augEffect = Instantiate (earthEffect, clone.transform.position, Quaternion.identity) as GameObject;
				augEffect.transform.parent = clone.transform;
			}
		}

		//Set when the next bullet can be fired
		nextFire = Time.time + (baseFireRate + fireRateModifier);
	}
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(swapKey))
        {
            print("swap key was pressed");
            StatsManager aManager = GetComponent <StatsManager> ();
            StatsManager bManager = twin.GetComponent <StatsManager> ();

            iAugment a = aManager.GetAugment();
            iAugment b = bManager.GetAugment();

            aManager.SetAugment(b);
            bManager.SetAugment(a);
        }
    }
Ejemplo n.º 5
0
	void FixedUpdate () {
		swapTrigger = Input.GetAxisRaw ("SwapAug" + playerPrefix);

		if (swapTrigger > 0 && Time.time > nextSwap) {
			tempAug = GetAugment();
			tempSpr = playerAugSprite.GetComponent<Image> ().sprite;

			SetAugment(otherPlayerStats.GetAugment ());
			playerAugSprite.GetComponent<Image>().sprite = otherPlayerAugSprite.GetComponent<Image>().sprite;

			otherPlayerStats.SetAugment (tempAug);
			otherPlayerAugSprite.GetComponent<Image>().sprite = tempSpr;

			nextSwap = Time.time + 2;
		}
	}
Ejemplo n.º 6
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.º 7
0
	// Use this for initialization
	void Start () {
		playerSpeedModifier = 0f;
		playerBulletSpeedModifier = 0f;
		playerFireRateModifier = 0f;
		playerAugment = null;
		playerPrefix = gameObject.name;

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

		otherPlayerStats = GameObject.Find (otherPlayerPrefix).GetComponent<StatsManager> ();
		playerAugSprite = GameObject.Find (playerPrefix + "Aug");
		otherPlayerAugSprite = GameObject.Find (otherPlayerPrefix + "Aug");
	}
Ejemplo n.º 8
0
    void Shoot(Vector3 shootDir)
    {
        aug = GetComponent <StatsManager> ().GetAugment();

        if (aug != null)
        {
            if (aug.Element == "fire")
            {
                cur_bullet = Red_bullet;
            }
            else if (aug.Element == "ice")
            {
                cur_bullet = Blue_bullet;
            }
            else if (aug.Element == "earth")
            {
                cur_bullet = Green_bullet;
            }
        }

        if (curWeap == "Pistol")
        {
            //Create the bullet and launch it
            GameObject clone = Instantiate(cur_bullet, pistolTip.transform.position, pistolTip.transform.rotation) as GameObject;
            //clone.transform.rotation = Quaternion.LookRotation (shootDir);
            Physics.IgnoreCollision(clone.GetComponent <Collider> (), GetComponent <Collider> ());
            clone.GetComponent <Rigidbody> ().velocity = (clone.transform.forward * baseBulletSpeed);
            if (aug != null)
            {
                clone.GetComponent <BulletBehavior> ().setAugment(aug);
            }
        }
        else if (curWeap == "Sword")
        {
            sword.GetComponent <PlayerSword> ().Swing();
        }

        //Set when the next bullet can be fired
        nextFire = Time.time + baseFireRate;
    }
Ejemplo n.º 9
0
	// Update is called once per frame
	void Update () {
		//Joystick Shooting	
		shootVert = Mathf.Round(Input.GetAxisRaw(shootButtonVert));
		shootHoriz  = Mathf.Round(Input.GetAxisRaw(shootButtonHoriz));
		shootingDir = new Vector3 (shootHoriz, 0f, shootVert);

		aug = GetComponent<StatsManager> ().GetAugment ();

		if (curWeap == "Sword") {
			sword.GetComponent<PlayerSword> ().setAugment (aug);
		};

		if (!HealthManager.isGameOver && !GamePause.isPaused && GameStats.gameStarted) {

			playerShooting = (Input.GetButton ("FireRight" + playerPrefix) ||
				Input.GetButton ("FireDown" + playerPrefix) ||
				Input.GetButton ("FireUp" + playerPrefix) ||
				Input.GetButton ("FireLeft" + playerPrefix) ||
				(shootVert != 0) ||
				(shootHoriz != 0));

			if (playerShooting && curWeap != "Sword") {
				RoomController roomController = gameObject.GetComponent<StatsManager>().RoomIn.GetComponent<RoomController>();
				roomController.EnemiesActive = true;
			}

			if (curWeap == "Sword") {
				playerSwinging = sword.GetComponent<PlayerSword> ().isSwinging;
			}
			
			//Player Shooting
			if (curWeap == "RayGun") {
				if (Input.GetButton ("FireRight" + playerPrefix)) {
					transform.rotation = Quaternion.LookRotation (Vector3.left);
					StopCoroutine ("FireLaser");
					StartCoroutine ("FireLaser");
				} else if (Input.GetButton ("FireDown" + playerPrefix)) {
					transform.rotation = Quaternion.LookRotation (Vector3.forward);
					StopCoroutine ("FireLaser");
					StartCoroutine ("FireLaser");
				} else if (Input.GetButton ("FireUp" + playerPrefix)) {
					transform.rotation = Quaternion.LookRotation (Vector3.back);
					StopCoroutine ("FireLaser");
					StartCoroutine ("FireLaser");
				} else if (Input.GetButton ("FireLeft" + playerPrefix)) {
					transform.rotation = Quaternion.LookRotation (Vector3.right);
					StopCoroutine ("FireLaser");
					StartCoroutine ("FireLaser");
				} else if (shootingDir.magnitude != 0) {
					transform.rotation = Quaternion.LookRotation (shootingDir * -1);
					StopCoroutine ("FireLaser");
					StartCoroutine ("FireLaser");
				}
			} else {
				if (Input.GetButton ("FireRight" + playerPrefix) && Time.time > nextFire) {
					transform.rotation = Quaternion.LookRotation (Vector3.left);
					Shoot (Vector3.right);
				} else if (Input.GetButton ("FireDown" + playerPrefix) && Time.time > nextFire) {
					transform.rotation = Quaternion.LookRotation (Vector3.forward);
					Shoot (Vector3.back);
				} else if (Input.GetButton ("FireUp" + playerPrefix) && Time.time > nextFire) {
					transform.rotation = Quaternion.LookRotation (Vector3.back);
					Shoot (Vector3.forward);
				} else if (Input.GetButton ("FireLeft" + playerPrefix) && Time.time > nextFire) {
					transform.rotation = Quaternion.LookRotation (Vector3.right);
					Shoot (Vector3.left);
				} else if (shootingDir.magnitude != 0 && Time.time > nextFire) {
					transform.rotation = Quaternion.LookRotation (shootingDir * -1);
					Shoot (shootingDir);
				}
			}
		}
	}
Ejemplo n.º 10
0
	public void SwapAugments() {
		hudReset = false;
		if (!swapLock) {
			swapLock = true;

			otherPlayerStats.RequestAugSwap = false;
			otherPlayerStats.DestroySwapPrompt();
			requestAugSwap = false;
			DestroySwapPrompt();

			tempAug = GetAugment();
			tempSpr = playerAugSprite.GetComponent<Image> ().sprite;

			SetAugment(otherPlayerStats.GetAugment ());
			playerAugSprite.GetComponent<Image>().sprite = otherPlayerAugSprite.GetComponent<Image>().sprite;

			otherPlayerStats.SetAugment (tempAug);
			otherPlayerAugSprite.GetComponent<Image>().sprite = tempSpr;

			swapLock = false;
		}
		nextAugSwap = Time.time + 4;
		swapAugTimeout = 0;
	}
Ejemplo n.º 11
0
	public void SetAugment (iAugment augment){
		playerAugment = augment;
		if (augment == null) {
			augmentName = "No Augment";
		} else {
			augmentName = augment.Element;
		}
	}
Ejemplo n.º 12
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.º 13
0
    IEnumerator FireLaser()
    {
        line.enabled = true;
        aug          = GetComponent <StatsManager> ().GetAugment();

        if (aug != null)
        {
            if (aug.Element == "fire")
            {
                rayGunTip.GetComponent <Renderer> ().material = Resources.Load <Material> ("LaserRed");
            }
            else if (aug.Element == "ice")
            {
                rayGunTip.GetComponent <Renderer> ().material = Resources.Load <Material> ("LaserBlue");
            }
            else if (aug.Element == "earth")
            {
                rayGunTip.GetComponent <Renderer> ().material = Resources.Load <Material> ("LaserGreen");
            }
        }
        else
        {
            rayGunTip.GetComponent <Renderer> ().material = Resources.Load <Material> ("LaserDefault");
        }

        while (playerShooting)
        {
            audioPlacement.PlayClip("beep/beep_2", 0.04f);
            Ray        ray = new Ray(rayGunTip.transform.position, transform.forward * -1);
            RaycastHit hit;

            line.SetPosition(0, ray.origin);

            if (Physics.Raycast(ray, out hit, 50))
            {
                line.SetPosition(1, hit.point);
                if (hit.transform.tag == "Enemy")
                {
                    string damageType = "none";
                    float  force      = 0;

                    if (aug != null)
                    {
                        aug.onHitEffect(hit.transform.gameObject);
                        damageType = aug.Element;

                        if (aug.Element == "earth")
                        {
                            force = 70;
                        }
                    }

                    //Add force to enemy
                    hit.rigidbody.AddForceAtPosition(transform.forward * force * -1, hit.point);
                    EnemyStats enemyHP = hit.transform.GetComponent <EnemyStats> ();
                    enemyHP.TakeDamage(0.18f, damageType);
                }
            }
            else
            {
                line.SetPosition(1, ray.GetPoint(50));
            }

            yield return(null);
        }
        line.enabled = false;
    }
Ejemplo n.º 14
0
    // Update is called once per frame
    void Update()
    {
        //Joystick Shooting
        shootVert   = Mathf.Round(Input.GetAxisRaw(shootButtonVert));
        shootHoriz  = Mathf.Round(Input.GetAxisRaw(shootButtonHoriz));
        shootingDir = new Vector3(shootHoriz, 0f, shootVert);

        aug = GetComponent <StatsManager> ().GetAugment();

        if (curWeap == "Sword")
        {
            sword.GetComponent <PlayerSword> ().setAugment(aug);
        }
        ;

        if (!HealthManager.isGameOver && !GamePause.isPaused && GameStats.gameStarted)
        {
            playerShooting = (Input.GetButton("FireRight" + playerPrefix) ||
                              Input.GetButton("FireDown" + playerPrefix) ||
                              Input.GetButton("FireUp" + playerPrefix) ||
                              Input.GetButton("FireLeft" + playerPrefix) ||
                              (shootVert != 0) ||
                              (shootHoriz != 0));

            if (playerShooting && curWeap != "Sword")
            {
                RoomController roomController = gameObject.GetComponent <StatsManager>().RoomIn.GetComponent <RoomController>();
                roomController.EnemiesActive = true;
            }

            if (curWeap == "Sword")
            {
                playerSwinging = sword.GetComponent <PlayerSword> ().isSwinging;
            }

            //Player Shooting
            if (curWeap == "RayGun")
            {
                if (Input.GetButton("FireRight" + playerPrefix))
                {
                    transform.rotation = Quaternion.LookRotation(Vector3.left);
                    StopCoroutine("FireLaser");
                    StartCoroutine("FireLaser");
                }
                else if (Input.GetButton("FireDown" + playerPrefix))
                {
                    transform.rotation = Quaternion.LookRotation(Vector3.forward);
                    StopCoroutine("FireLaser");
                    StartCoroutine("FireLaser");
                }
                else if (Input.GetButton("FireUp" + playerPrefix))
                {
                    transform.rotation = Quaternion.LookRotation(Vector3.back);
                    StopCoroutine("FireLaser");
                    StartCoroutine("FireLaser");
                }
                else if (Input.GetButton("FireLeft" + playerPrefix))
                {
                    transform.rotation = Quaternion.LookRotation(Vector3.right);
                    StopCoroutine("FireLaser");
                    StartCoroutine("FireLaser");
                }
                else if (shootingDir.magnitude != 0)
                {
                    transform.rotation = Quaternion.LookRotation(shootingDir * -1);
                    StopCoroutine("FireLaser");
                    StartCoroutine("FireLaser");
                }
            }
            else
            {
                if (Input.GetButton("FireRight" + playerPrefix) && Time.time > nextFire)
                {
                    transform.rotation = Quaternion.LookRotation(Vector3.left);
                    Shoot(Vector3.right);
                }
                else if (Input.GetButton("FireDown" + playerPrefix) && Time.time > nextFire)
                {
                    transform.rotation = Quaternion.LookRotation(Vector3.forward);
                    Shoot(Vector3.back);
                }
                else if (Input.GetButton("FireUp" + playerPrefix) && Time.time > nextFire)
                {
                    transform.rotation = Quaternion.LookRotation(Vector3.back);
                    Shoot(Vector3.forward);
                }
                else if (Input.GetButton("FireLeft" + playerPrefix) && Time.time > nextFire)
                {
                    transform.rotation = Quaternion.LookRotation(Vector3.right);
                    Shoot(Vector3.left);
                }
                else if (shootingDir.magnitude != 0 && Time.time > nextFire)
                {
                    transform.rotation = Quaternion.LookRotation(shootingDir * -1);
                    Shoot(shootingDir);
                }
            }
        }
    }
Ejemplo n.º 15
0
	void Shoot (Vector3 shootDir) {

		aug = GetComponent<StatsManager> ().GetAugment ();

		if (aug != null) {
			if (aug.Element == "fire") {
				cur_bullet = Red_bullet;
			} else if (aug.Element == "ice") {
				cur_bullet = Blue_bullet;
			} else if (aug.Element == "earth") {
				cur_bullet = Green_bullet;
			}
		}

		if (curWeap == "Pistol") {
			//Create the bullet and launch it
			GameObject clone = Instantiate (cur_bullet, pistolTip.transform.position, pistolTip.transform.rotation) as GameObject;
			//clone.transform.rotation = Quaternion.LookRotation (shootDir);
			Physics.IgnoreCollision (clone.GetComponent<Collider> (), GetComponent<Collider> ());
			clone.GetComponent<Rigidbody> ().velocity = (clone.transform.forward * baseBulletSpeed);
			if (aug != null) {
				clone.GetComponent<BulletBehavior> ().setAugment (aug);
			}

		} else if (curWeap == "Sword") {
			sword.GetComponent<PlayerSword> ().Swing ();
		}

		//Set when the next bullet can be fired
		nextFire = Time.time + baseFireRate;
	}
Ejemplo n.º 16
0
	public void setAugment(iAugment aug){
		augment = aug;
	}
Ejemplo n.º 17
0
	IEnumerator FireLaser() {
		line.enabled = true;
		aug = GetComponent<StatsManager> ().GetAugment ();

		if (aug != null) {
			if (aug.Element == "fire") {
				rayGunTip.GetComponent<Renderer> ().material = Resources.Load<Material> ("LaserRed");
			} else if (aug.Element == "ice") {
				rayGunTip.GetComponent<Renderer> ().material = Resources.Load<Material> ("LaserBlue");
			} else if (aug.Element == "earth") {
				rayGunTip.GetComponent<Renderer> ().material = Resources.Load<Material> ("LaserGreen");
			}
		} else {
			rayGunTip.GetComponent<Renderer> ().material = Resources.Load<Material> ("LaserDefault");
		}

		while (playerShooting) 
		{
			audioPlacement.PlayClip("beep/beep_2", 0.04f);
			Ray ray = new Ray (rayGunTip.transform.position, transform.forward * -1);
			RaycastHit hit;

			line.SetPosition (0, ray.origin);

			if (Physics.Raycast(ray, out hit, 50)) {
				line.SetPosition(1, hit.point);
				if (hit.transform.tag == "Enemy") {
					string damageType = "none";
					float force = 0;

					if (aug != null) {
						aug.onHitEffect (hit.transform.gameObject);
						damageType = aug.Element;

						if (aug.Element == "earth") {
							force = 70;

						}
					}

					//Add force to enemy
					hit.rigidbody.AddForceAtPosition(transform.forward * force * -1, hit.point);
					EnemyStats enemyHP = hit.transform.GetComponent<EnemyStats> ();
					enemyHP.TakeDamage (0.18f, damageType);
				}
			} else {
				line.SetPosition (1, ray.GetPoint (50));
			}

			yield return null;
		}
		line.enabled = false;
	}
Ejemplo n.º 18
0
 public void setAugment(iAugment aug)
 {
     augment = aug;
 }
Ejemplo n.º 19
0
	public void setAugment(iAugment aug){
		Debug.Log ("On-hit effects set");
		augment = aug;
	}