コード例 #1
0
    public void Swing()
    {
        isSwinging = true;

        AP.PlayClip("SFX/sword", 0.1f);
        if (augment != null)
        {
            if (augment.Element == "fire")
            {
                trailColor = Resources.Load <Material>("RedTrail");
            }
            else if (augment.Element == "ice")
            {
                trailColor = Resources.Load <Material>("BlueTrail");
            }
            else if (augment.Element == "earth")
            {
                trailColor = Resources.Load <Material>("GreenTrail");
            }
        }
        else
        {
            trailColor = Resources.Load <Material>("WhiteTrail");
        }

        swordTrail.GetComponent <TrailRenderer>().material = trailColor;
        swordAnimator.SetTrigger("Attack");
        StartCoroutine("WaitAndStop");
    }
コード例 #2
0
ファイル: StatsManager.cs プロジェクト: Grochoci/Symbiosis
    IEnumerator PlaySound()
    {
        swapCooldownSoundNotPlaying = false;
        audioPlacement.PlayClip("EarlySwap", 0.1f);
        nextAugSwapFailedSound = false;
        yield return(new WaitForSeconds(0.7f));

        swapCooldownSoundNotPlaying = true;
    }
コード例 #3
0
    void OnTriggerEnter(Collider c)
    {
        GameObject other = c.gameObject;

        //If it hits a player don't disappear
        if (other.tag != "Player" && other.tag != "Bullet" && other.tag != "Room" && other.tag != "TutorialRoom" && other.tag != "Pickups" && other.tag != "Pipe")
        {
            AP.PlayClip("SFX/bullet_die", 0.05f);
            Destroy(gameObject);
        }
        if (other.tag == "Bullet" || other.tag == "Pickups")
        {
            Physics.IgnoreCollision(other.GetComponent <Collider> (), GetComponent <Collider> ());
        }

        if (other.tag == "Enemy")
        {
            string damageType = "none";
            float  force      = 50;
            if (augment != null)
            {
                Debug.Log("");
                //Destroy (collision.gameObject);
                augment.onHitEffect(other);
                damageType = augment.Element;
                if (augment.Element == "earth")
                {
                    force = 1000;
                }
            }

            Vector3 bulletDir = this.gameObject.transform.forward;
            bulletDir.y = 0;
            other.GetComponent <Rigidbody> ().AddForce(bulletDir.normalized * force);

            EnemyStats enemyHP = other.GetComponent <EnemyStats>();
            enemyHP.TakeDamage(bulletDamage, damageType);
        }
    }
コード例 #4
0
ファイル: Pickups.cs プロジェクト: Grochoci/Symbiosis
    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;
                }
            }
        }
    }
コード例 #5
0
	// Use this for initialization
	void Start () {
		AP = GameObject.Find ("AudioListener").GetComponent<AudioPlacement> ();
		AP.PlayClip ("SFX/bullet_fire", 0.1f);
	}
コード例 #6
0
 // Use this for initialization
 void Start()
 {
     AP = GameObject.Find("AudioListener").GetComponent <AudioPlacement> ();
     AP.PlayClip("SFX/bullet_fire", 0.1f);
 }
コード例 #7
0
ファイル: PlayerShooting.cs プロジェクト: Grochoci/Symbiosis
    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;
    }