Пример #1
0
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == "StreamBugHazard")
        {
            StreamBugHazardScript sbh = col.gameObject.GetComponent <StreamBugHazardScript> ();
            if (sbh.isHarmful)
            {
                float damage = sbh.damage;
                //damage = 0;
                if (invincibleTimer <= 0f)
                {
                    if (damage > lives)
                    {
                        lives = 0;
                    }
                    else
                    {
                        lives          -= damage;
                        invincibleTimer = invincibleOnHitTime;
                    }

                    Globals.treeManager.mainTree.GlowRed();
                    //Debug.Log("glowing red called");
                    //Globals.treeManager.mainTree.startShake();
                }
                sbh.isHarmful = false;
            }
        }
    }
Пример #2
0
    public void MakeBug(Globals.HazardColors c)
    {
        //Now all bugs are created in one fell swoop
        while (bugCounter <= totalBugs)
        {
            float ang  = Mathf.Deg2Rad * (90f + aimedAngle);
            float dist = (Utils.distanceScale + speed * Camera.main.orthographicSize * (arrivalTime + totalDuration / totalBugs * (bugCounter - 1)));
            x = Globals.target.x + Mathf.Cos(ang) * dist;
            y = Globals.target.y + Mathf.Sin(ang) * dist;
            GameObject            go  = Instantiate(bugPrefab, new Vector3(x, y, 0), Quaternion.identity) as GameObject;
            StreamBugHazardScript sbh = go.GetComponent <StreamBugHazardScript>();
            sbh.color = c;
            sbh.speed = speed;
            sbh.angle = aimedAngle - 180f;

            //Vector2 scale = go.GetComponent<_Mono>().xys;
            //go.GetComponent<_Mono>().xys = Camera.main.orthographicSize / initialCameraSize * scale;

            bugTimer                -= totalDuration / totalBugs;
            sbh.streamMember         = bugCounter;
            sbh.streamTotal          = totalBugs;
            sbh.damage               = damage;
            sbh.ccs                  = ccs;
            ccs.bugs[bugCounter - 1] = sbh;

            AngleChange();
        }
    }