Esempio n. 1
0
    private void OnTriggerEnter2D(Collider2D Collider)
    {
        if (Collider.gameObject.name.Contains("cloud"))
        {
            cloud cloudScript = Collider.gameObject.GetComponent <cloud>();
            Debug.Log(cloudScript.type);

            if (cloudScript.type == "button")
            {
                Debug.Log("Yes! Good!");
                cloudScript.act = true;
                cloudScript.interact();
            }
            else if (cloudScript.type == "bounce")
            {
                if (cloudScript.act)
                {
                    Debug.Log("BounceON");
                    rb2d.AddForce(new Vector2(0f, 100f * Mathf.Abs(rb2d.velocity.y)));
                    //Collider.gameObject.GetComponent<BoxCollider2D>().GetComponent<PhysicsMaterial2D>().bounciness = 1;
                }
            }
        }
        if (Collider.gameObject.name.Contains("cloud"))
        {
            if (Collider.gameObject.GetComponent <cloud>().type.Contains("moving"))
            {
                Debug.Log("Move");
                transform.parent = Collider.transform;
            }
        }
    }
Esempio n. 2
0
 //Spawn a new cloud if the correct time has elapsed
 void spawnCloud(float spawnTime)
 {
     spawnTimer += Time.deltaTime;
     if (spawnTimer > spawnTime && levelTimer > 3)
     {
         //Reset timer, spawn cloud and give it a speed of 200.0f
         spawnTimer = 0.0f;
         cloud newCloud = Instantiate(cloudPrefab, transform.position + (Vector3.up * Random.Range(-5.0f, 5.0f)), transform.rotation) as cloud;
         newCloud.speed = 200.0f;
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        radius = 0.5f;
        cloud  = GameObject.Find("cloud").GetComponent <cloud>();
        pn     = GameObject.Find("floor").GetComponent <PerlinNoise>();

        cb = this.GetComponent <CannonBall>();

        xMin = pn.xMin - 1f;
        xMax = pn.xMax + 1f;
        yMin = pn.yMin - 1f;
        yMax = pn.yMax + 1f;

        //bound box is a big axis aligned bounding box around the stonehedge
        boundBox = new Rectangle(new Vector2(xMin, yMin), new Vector2(xMin, yMax), new Vector2(xMax, yMax), new Vector2(xMax, yMin));

        //cBall is an object representing the cannonball
        cBall       = new Circle(new Vector2(transform.position.x, transform.position.y));
        cBallNext   = new Circle();
        cBallHitBox = new Rectangle();
    }
    void Start()
    {
        screenHeight = camera.orthographicSize;
        screenWidth  = screenHeight * camera.aspect;

        GameObject tip = GameObject.Find("tipOfCannon");

        transform.position = tip.transform.position;

        theta = tip.transform.parent.transform.eulerAngles.z;
        vix   = -launchSpeed *Mathf.Sin(theta *(Mathf.PI / 180)); //sin and cos reversed for Initial x and Initial y velocity because theta = 0 along y axis

        //add negative sign because vix is in left direction (-x direction)
        viy = launchSpeed * Mathf.Cos(theta * (Mathf.PI / 180));

        x = transform.position.x;
        y = transform.position.y;

        cloud = GameObject.Find("cloud").GetComponent <cloud>();

        cannon = GameObject.Find("cannonRectangle").GetComponent <cannon>();
    }
Esempio n. 5
0
 public static void printCloud(cloud d)
 {
     Console.WriteLine(d());
 }