Пример #1
0
    void upgrade_if_better(GameObject crate)
    {
        CrateContents   cc  = crate.GetComponent <CrateContents>();
        ShipStatsScript sss = GetComponent <ShipStatsScript>();

        if (cc.type == Constants.UpgradeTypes.topSpeed)
        {
            if (cc.value + sss.topSpeed > sss.topSpeed)
            {
                sss.topSpeed = cc.value;
            }
        }
        else if (cc.type == Constants.UpgradeTypes.SHIELD)
        {
            if (cc.value > sss.shield)
            {
                sss.shield = cc.value;
            }
        }
        else if (cc.type == Constants.UpgradeTypes.ACCELERATION)
        {
            if (cc.value > sss.acceleration)
            {
                sss.acceleration = cc.value;
            }
        }
        else if (cc.type == Constants.UpgradeTypes.TURNSPEED)
        {
            if (cc.value > sss.turnspeed)
            {
                sss.turnspeed = cc.value;
            }
        }
    }
Пример #2
0
 void OnTriggerEnter(Collider coll)
 {
     if (coll.gameObject.tag == "upgradecrate")
     {
         upgrade_if_better(coll.gameObject);
         cs.GetComponent <CrateSpawnerScript>().return_crate(coll.gameObject);
     }
     else if (coll.gameObject.tag == "upgradefrontgun")
     {
         // What do we want to do here?
         Destroy(coll.gameObject);
     }
     else if (coll.gameObject.tag == "upgradesidegun")
     {
         // What do we want to do here?
         Destroy(coll.gameObject);
     }
     else if (coll.gameObject.tag == "shell")
     {
         // Week08 Week 08
         ShipStatsScript sss         = GetComponent <ShipStatsScript>();
         ShellScript     shellScript = coll.gameObject.GetComponent <ShellScript>();
         sss.take_damage(shellScript.damage);
         shellHolderScript.return_shell(coll.gameObject);
         shellHolderScript.get_Exp();
         //coll.point
     }
     else if (coll.gameObject.tag == "mine")
     {
         ShipStatsScript sss        = GetComponent <ShipStatsScript>();
         MineScript      mineScript = coll.gameObject.GetComponent <MineScript>();
         sss.take_damage(mineScript.damage);
     }
 }
Пример #3
0
    //Vector3 cameraZoom;

    // Use this for initialization
    void Start()
    {
        ShipStatsScript sss = this.gameObject.GetComponent <ShipStatsScript>();

        sss.health += sss.health;
        cameras     = FindObjectsOfType <Camera>();
        //cameraZoom = cameras[0].transform.localPosition;
    }
Пример #4
0
    void OnCollisionEnter(Collision col)
    {
        if (debuggerScript == null)
        {
            Debug.Log("DebuggerScript null");
        }

        if (debugShellImpact == true)
        {
            Debug.Log("hit " + col.gameObject.name);
        }
        if (col.gameObject.name != gameObject.name && col.gameObject.layer == 9)
        {
            ShipStatsScript sss  = col.gameObject.GetComponent <ShipStatsScript>();
            ContactPoint    cont = col.contacts[0]; // new ContactPoint
            exp = shellHolderScript.get_Exp();
            if (!exp)
            {
                Debug.Log("Exp is null");
            }
            exp.transform.position = cont.point;
            // exp.transform.position = gameObject.transform.position;


            shellHolderScript.invoke_return_Exp(exp);

            sss.take_damage(damage);
            damage = Constants.MINIMUMDAMAGE;
        }

        if (col.gameObject.tag == "water")
        {
/*          ContactPoint cont = col.contacts[0];   // new ContactPoint
 *                      GameObject splash = Instantiate(splashPref, cont.point, Quaternion.identity);
 *                      Destroy(splash, 3.0f); */
        }
    }
    public void OnTriggerStay2D(Collider2D coll)
    {
        if (coll.gameObject.tag == "Ship" && stop == true)
        {
            ShipStatsScript ship = coll.gameObject.GetComponent <ShipStatsScript>();
            if (!ship.IsPhasing)
            {
                ship.TakeHarm(Random.Range(MinDam * 5, MaxDam * 5 + 1));
            }
        }
        else if (coll.gameObject.tag == "Enemy")
        {
            if (coll.gameObject.GetComponent <BadguyStatsScript>() != null)
            {
                if (coll.gameObject.GetComponent <BossScript>() == null)
                {
                    BadguyStatsScript ship = coll.gameObject.GetComponent <BadguyStatsScript>();
                    ship.TakeHarm(Random.Range(MinDam, MaxDam + 1));
                }
                else
                {
                    BadguyStatsScript ship = coll.gameObject.GetComponent <BadguyStatsScript>();
                    ship.TakeHarm(1);
                }
            }

            bool foundExplodeSound = false;
            foreach (PlayImpactScript child in ExplosionFinderScript.FindExplode.GetComponentsInChildren <PlayImpactScript>(true))
            {
                if (!child.gameObject.activeSelf)
                {
                    foundExplodeSound = true;
                    child.gameObject.transform.position = transform.position;
                    child.gameObject.SetActive(true);
                    child.SetClip(ImpactSound);
                    child.PlaySound();

                    break;
                }
            }

            if (!foundExplodeSound)
            {
                PlayImpactScript impact = Instantiate(Impact, transform.position, Quaternion.identity);
                impact.SetClip(ImpactSound);
                impact.PlaySound();
            }



            bool foundExplode = false;
            foreach (ParticleDestoryScript child in ExplosionFinderScript.FindExplode.GetComponentsInChildren <ParticleDestoryScript>(true))
            {
                if (!child.gameObject.activeSelf)
                {
                    child.gameObject.transform.position = transform.position;
                    if (child.GetComponent <ParticleSystem>() != null)
                    {
                        child.gameObject.SetActive(true);
                        child.gameObject.GetComponent <ParticleSystem>().Play();
                        foundExplode = true;
                        break;
                    }
                }
            }
            if (!foundExplode)
            {
                Instantiate(impactExplosion, transform.position, Quaternion.identity);
            }
        }
    }
 // Use this for initialization
 void Start()
 {
     rb  = GetComponent <Rigidbody>();
     sss = GetComponent <ShipStatsScript>();
 }