示例#1
0
    void Start()
    {
        // INFO: Make connection with orb script
        GameObject orb = GameObject.FindWithTag("Orb");

        orbScript = orb.GetComponent <OrbScript>();
    }
示例#2
0
 void Start()
 {
     orbScript = orbObj.GetComponent <OrbScript>();
     swipeCode = playerObject.GetComponent <SwipeCode>();
     CheckTutorialAvailable();
     positionOperator = MainframeBody.GetComponent <PositionOperator>();
 }
示例#3
0
 void DropOrbs()
 {
     if (canUseWeapon0)
     {
         OrbScript orb = Instantiate <OrbScript>(orbPrefab, transform.position + new Vector3(Random.Range(0f, 0.5f), 0.8f, Random.Range(0f, 0.5f)), Quaternion.identity);
         orb.weaponIndex = 0;
         orb.GetComponent <MeshRenderer>().material.SetColor("_Color", grid.colors[0]);
         orb.Drop();
     }
     if (canUseWeapon1)
     {
         OrbScript orb = Instantiate <OrbScript>(orbPrefab, transform.position + new Vector3(Random.Range(0f, 0.5f), 0.8f, Random.Range(0f, 0.5f)), Quaternion.identity);
         orb.weaponIndex = 1;
         orb.GetComponent <MeshRenderer>().material.SetColor("_Color", grid.colors[1]);
         orb.Drop();
     }
     if (canUseWeapon2)
     {
         OrbScript orb = Instantiate <OrbScript>(orbPrefab, transform.position + new Vector3(Random.Range(0f, 0.5f), 0.8f, Random.Range(0f, 0.5f)), Quaternion.identity);
         orb.weaponIndex = 2;
         orb.GetComponent <MeshRenderer>().material.SetColor("_Color", grid.colors[2]);
         orb.Drop();
     }
     if (canUseWeapon3)
     {
         OrbScript orb = Instantiate <OrbScript>(orbPrefab, transform.position + new Vector3(Random.Range(0f, 0.5f), 0.8f, Random.Range(0f, 0.5f)), Quaternion.identity);
         orb.weaponIndex = 3;
         orb.GetComponent <MeshRenderer>().material.SetColor("_Color", grid.colors[3]);
         orb.Drop();
     }
 }
示例#4
0
    // collision check with orbs
    private void OnTriggerEnter(Collider other)
    {
        OrbScript orb = other.GetComponent <OrbScript>();

        if (orb != null)
        {
            if (orb.weaponIndex == 0)
            {
                canUseWeapon0 = true;
                exit.UpdateOrb(0, true);
                ui.UpdateOrb(0, true);
            }
            else if (orb.weaponIndex == 1)
            {
                canUseWeapon1 = true;
                exit.UpdateOrb(1, true);
                ui.UpdateOrb(1, true);
            }
            else if (orb.weaponIndex == 2)
            {
                canUseWeapon2 = true;
                exit.UpdateOrb(2, true);
                ui.UpdateOrb(2, true);
            }
            else if (orb.weaponIndex == 3)
            {
                canUseWeapon3 = true;
                exit.UpdateOrb(3, true);
                ui.UpdateOrb(3, true);
            }
            Destroy(other.gameObject);
        }
    }
    // Update is called once per frame
    void Update()
    {
        Vector3 _screenPos  = Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, Screen.height));
        int     randomIndex = Random.Range(0, 4);

        currentTimer -= Time.deltaTime;

        if (currentTimer <= 0)
        {
            currentTimer = timer;

            if (randomIndex == 0)
            {
                OrbScript _orbClone = Instantiate(orb, new Vector3(-_screenPos.x - 0.1f, Random.Range(-_screenPos.y, _screenPos.y), 0), Quaternion.identity);
            }
            else if (randomIndex == 1)
            {
                OrbScript _orbClone = Instantiate(orb, new Vector3(_screenPos.x + 0.1f, Random.Range(-_screenPos.y, _screenPos.y), 0), Quaternion.identity);
            }
            else if (randomIndex == 2)
            {
                OrbScript _orbClone = Instantiate(orb, new Vector3(Random.Range(-_screenPos.x, _screenPos.x), -_screenPos.y - 0.1f, 0), Quaternion.identity);
            }
            else if (randomIndex == 3)
            {
                OrbScript _orbClone = Instantiate(orb, new Vector3(Random.Range(-_screenPos.x, _screenPos.x), _screenPos.y + 0.1f, 0), Quaternion.identity);
            }
        }
    }
示例#6
0
 void Start()
 {
     mainframeActionSelection = mainframe.GetComponent <MainframeActionSelection>();
     follower  = GetComponent <SplineFollower>();
     arrayTest = gameManager.GetComponent <ArrayTest>();
     orbScript = orb.GetComponent <OrbScript>();
     DifficultyScript.elapsedTime = Time.time;
 }
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (orbScript == null)
        {
            orbScript = animator.gameObject.GetComponent <OrbScript>();
        }

        orbScript.ToggleExplosionTrigger(true);
    }
示例#8
0
 public void deathOrb(OrbScript orb)
 {
     if (orb.GetOrbColor() != OrbScript.OrbColor.Red)
     {
         greenOrbs.Remove(orb);
     }
     else
     {
         redOrbs.Remove(orb);
     }
     Destroy(orb.gameObject);
 }
    IEnumerator ThrowOrb()
    {
        while (isPlayerSeen)
        {
            trajectory  = (playerObj.transform.position - gameObject.transform.position).normalized;
            isCRStarted = true;
            orbThrowObj = Instantiate(orbObj, new Vector3(transform.position.x, transform.position.y, transform.position.z), Quaternion.identity) as GameObject;
            OrbScript orbScript = orbThrowObj.GetComponent <OrbScript>();
            orbScript.trajectory = trajectory;
            yield return(new WaitForSeconds(1.5f));
        }

        isCRStarted = false;
    }
示例#10
0
 void Start()
 {
     orbScript          = particles.GetComponent <OrbScript>();
     cameraMovement     = mainCameraObject.GetComponent <CameraMovement>();
     topScoreScript     = TopScoreHolder.GetComponent <TopScore>();
     GUIMainframeBody   = MainframeBody.GetComponent <SplineFollower>();
     GUImainCamera      = mainCamera.GetComponent <SplineFollower>();
     playMesh           = playIcon.GetComponent <MeshRenderer>();
     arrayTest          = gameManager.GetComponent <ArrayTest>();
     guiMainframeScript = MainframeBody.GetComponent <GUImainframeScript>();
     score            = gameManager.GetComponent <Score>();
     adManager        = Ads.GetComponent <AdManager>();
     positionOperator = MainMainframeBody.GetComponent <PositionOperator>();
     tutorialScript   = GetComponent <TutorialScript>();
 }
示例#11
0
    //handles laser interactions
    IEnumerator FireLaser()
    {
        laser.enabled = true;
        bool shot = false; //boolean to ensure that orbsShot in PlayerScript is only incremented once per shot

        //keeps laser visible while user is holding left click
        while (Input.GetButton("Fire1"))
        {
            Ray        ray = new Ray(transform.position, transform.forward); //make 100-ft ray from end of gun
            RaycastHit hit;                                                  //stores information about what laser touches

            laser.SetPosition(0, ray.origin);

            //handles laser collision with object
            if (Physics.Raycast(ray, out hit, 100))
            {
                OrbScript hitOrb = hit.collider.gameObject.GetComponent <OrbScript>(); //orb that laser is touching
                laser.SetPosition(1, hit.point);

                //if an orb is shot
                if (hitOrb != null)
                {
                    if (!shot && !hitOrb.IsShot())                                    //increment orbsShot only if orb wasn't shot already
                    {
                        transform.root.GetComponent <PlayerScript>().IncrementOrbs(); //gets PlayerScript as grandparent of gameObject laser comes from
                    }
                    hitOrb.disappear();                                               //make orb disappear
                    shot = true;
                }
            }
            else
            {
                laser.SetPosition(1, ray.GetPoint(100));
            }
            laser.SetPosition(1, ray.GetPoint(100));

            yield return(null);
        }

        laser.enabled = false; //make laser invisible when left click is released
    }
示例#12
0
    // Use this for initialization
    void Start()
    {
        Transform canvas = GameObject.Find("Canvas").transform;

        for (float i = 0.0f; i < (float)GridSize; i += 1.0f)
        {
            for (float j = 0.0f; j < (float)GridSize; j += 1.0f)
            {
                GameObject orbClone = (GameObject)Instantiate(orb);
                orbClone.transform.SetParent(canvas, true);
                orbClone.transform.localScale    = new Vector3(1.0f, 1.0f, 1);
                orbClone.transform.localPosition = new Vector3((i - 2) * 110, (j - 5.0f) * 110, 0);

                OrbScript os = orbClone.GetComponent <OrbScript>();
                os.orbType = Random.Range(0, 3);
                os.UpdateColor();
                os.row = (int)j;
                os.col = (int)i;
                orbArray[(int)j, (int)i] = orbClone;
            }
        }
    }
示例#13
0
 public void touchOrb(OrbScript orb)
 {
     if (!paused)
     {
         if (orb.GetOrbColor() == OrbScript.OrbColor.Red)
         {
             GetComponent <AudioSource>().clip = balloon;
             GetComponent <AudioSource>().Play();
             KillAllOrbs();
             gameover.EndGame();
             music.Stop();
         }
         else
         {
             if (orb.GetOrbColor() == OrbScript.OrbColor.Gold)
             {
                 GetComponent <AudioSource>().clip = goldPop;
                 GetComponent <AudioSource>().Play();
             }
             else
             {
                 int randomSound = Random.Range(0, 2);
                 GetComponent <AudioSource>().clip = pop[randomSound];
                 GetComponent <AudioSource>().Play();
             }
             if (orb.GetOrbColor() == OrbScript.OrbColor.Gold)
             {
                 score += 5;
             }
             else
             {
                 score++;
             }
             scoreText.text = "" + score;
         }
         deathOrb(orb);
     }
 }
示例#14
0
 private void Start()
 {
     bar          = transform.Find("Bar");
     theOrbScript = orbObject.GetComponent <OrbScript>();
 }
示例#15
0
    void Awake()
    {
        foreach (Transform t in transform)
        {
            Destroy(t.gameObject);
        }

        buildingLayerMask = LayerMask.GetMask("Buildings");

        // random temple start positions
        temples[0] = new Vector3(Mathf.Floor(Random.Range(1, 4)), 0, Mathf.Floor(Random.Range(1, 4)));
        temples[1] = new Vector3(Mathf.Floor(Random.Range(1, 4)), 0, Mathf.Floor(Random.Range(5, 9)));
        temples[2] = new Vector3(Mathf.Floor(Random.Range(5, 9)), 0, Mathf.Floor(Random.Range(1, 4)));
        temples[3] = new Vector3(Mathf.Floor(Random.Range(5, 9)), 0, Mathf.Floor(Random.Range(5, 9)));

        int   orbRandomizer = Random.Range(0, templesCount);
        float noiseOffset   = Random.Range(0f, 100f);

        squares = new Square[gridWidth * gridHeight];
        for (int x = 0; x < gridWidth; x++)
        {
            for (int z = 0; z < gridHeight; z++)
            {
                int   i = x * gridWidth + z;
                float y = Mathf.PerlinNoise((float)x / gridWidth + noiseOffset, (float)z / gridHeight + noiseOffset) * heightScale;

                squares[i].cube = Instantiate(floorPrefab, new Vector3(x + .5f, y - 1, z + .5f), Quaternion.identity);
                squares[i].cube.transform.parent = transform;
                squares[i].color = Color.Lerp(lowColor, highColor, y * (1 - minHeight) + minHeight);
                squares[i].top   = squares[i].cube.transform.position + new Vector3(0, squares[i].cube.transform.localScale.y / 2, 0);

                SpriteRenderer cubeSprite = squares[i].cube.GetComponentInChildren <SpriteRenderer>();
                cubeSprite.sprite = floorSprites[Random.Range(0, floorSprites.Length)];
                cubeSprite.color  = squares[i].color;

                Color buildingColor = Color.Lerp(lowColor, highColor, ((y - .5f) * buildingColorDamp + .5f) * (1 - minHeight) + minHeight);

                // place temples and orbs
                bool templePlaced = false;
                for (int j = 0; j < templesCount; j++)
                {
                    if (x == temples[j].x && z == temples[j].z)
                    {
                        OrbScript orb = Instantiate <OrbScript>(orbPrefab, new Vector3(x + .5f, y + .8f, z + .5f), Quaternion.Euler(0, 0, 0));
                        orb.weaponIndex = (j + orbRandomizer) % templesCount;
                        orb.GetComponent <MeshRenderer>().material.SetColor("_Color", colors[orb.weaponIndex]);
                        orb.GetComponent <MeshRenderer>().enabled = false;

                        TempleScript temple = Instantiate <TempleScript>(templePrefab, new Vector3(x + .5f, y, z + .5f), Quaternion.Euler(0, 0, 0));
                        templePlaced = true;
                        temple.transform.Find("Base").GetComponent <SpriteRenderer>().color = buildingColor;
                        temple.transform.Find("Mask").GetComponent <SpriteRenderer>().color = colors[orb.weaponIndex];
                        temple.orb = orb;
                    }
                }

                // place buildings
                if (!templePlaced && Mathf.Abs(x - z) < Mathf.Min(gridWidth, gridHeight) - 3)
                {
                    if (Random.value < buildingChance)
                    {
                        GameObject     building       = Instantiate(buildingPrefab, new Vector3(x + .5f, y, z + .5f), Quaternion.identity);
                        SpriteRenderer buildingSprite = building.GetComponentInChildren <SpriteRenderer>();
                        buildingSprite.sprite = buildingSprites[Random.Range(0, buildingSprites.Length)];
                        buildingSprite.color  = buildingColor;
                    }
                    else if (Random.value < eggChance)
                    {
                        Instantiate(eggPrefab, new Vector3(x + .5f, y, z + .5f), Quaternion.identity);
                    }
                }
            }
        }
    }