Example #1
0
    // Use this for initialization
    void Start()
    {
        int index = Random.Range(0, randomAtoms.Length);

        AtomCollector.AtomRatio atomAmo = new AtomCollector.AtomRatio();
        atomAmo.atom  = randomAtoms[index];
        atomAmo.ratio = amo;

        atomCollector  = atomCollector ?? GetComponent <AtomCollector>();
        spriteRenderer = spriteRenderer ?? GetComponent <SpriteRenderer>();

        if (atomCollector == null)
        {
            print("Could not find Atom Collector on " + name);
            return;
        }

        if (randomColors.Length > index)
        {
            spriteRenderer.color     = randomColors[index];
            atomCollector.aliveColor = randomColors[index];
        }


        atomCollector.AddAtom(atomAmo);
    }
Example #2
0
    public void CheckForCollect()
    {
        // Hovering over UI Object
        if (Input.GetMouseButton(0) && !cursor.IsOverUIElement())
        {
            var playerData = Game.Instance.playerData;

            Ray          ray = camera.ScreenPointToRay(Input.mousePosition);
            RaycastHit[] hit = Physics.SphereCastAll(ray, playerData.GetValue
                                                         (PlayerData.UpgradeType.Collect_Radius), 20.0f, AtomCollectorLayerMask, QueryTriggerInteraction.Collide);

            Vector3 pos       = Input.mousePosition;
            bool    collected = false;
            for (int i = 0; i < hit.Length; i++)
            {
                AtomCollector collector = hit[i].collider.GetComponent <AtomCollector>();

                var atoms = collector.Absorb();
                //if (!collector.CanBeCollected()) {
                //    collected = true;
                //}

                for (int y = 0; y < atoms.Count; y++)
                {
                    Game.Instance.PlayEffect(atoms[y].atom, atoms[y].amo, pos);
                    collected       = true;
                    lastCollectTime = Time.time;
                }
            }


            if (collected || Time.time - lastCollectTime < .1f)   // Check if we are or have collected atoms previously.
            {
                if (!collectSource.isPlaying)
                {
                    collectSource.clip = collectSound;
                    collectSource.Play();
                }
            }
            else
            {
                //if (!collectSource.isPlaying) {
                //    collectSource.clip = errorSound;
                //    collectSource.Play();
                //}
            }
        }
    }
Example #3
0
    public void Story()
    {
        switch (Game.Instance.story.GetChapter())
        {
        case 1:
            break;

        default:
            if (hydrogenTree != null)
            {
                hydrogenTree.gameObject.SetActive(false);
                Destroy(hydrogenTree.gameObject);
                hydrogenTree = null;
            }
            break;
        }
    }