Exemplo n.º 1
0
    public void RecruitMole()
    {
        int cost = 5;

        if (GameManager.Singleton.Stock.Caps < cost)
        {
            return;
        }

        GameManager.Singleton.Stock.Caps -= cost;

        Mole mole = _moleCreator.Create();

        GameObject moleObj = Instantiate(molePrefab, transformSpawn.position, Quaternion.identity);

        moleObj.transform.SetParent(container.transform, false);

        MoleBehaviour moleBehaviour = moleObj.GetComponent <MoleBehaviour>();

        moleBehaviour.Setup(mole);
        moleBehaviour.linePosition = moleBehaviours.Count + 1;
        moleBehaviour.OnReady     += OnMoleReady;

        moleBehaviours.Add(moleBehaviour);

        recruitButton.interactable = moleBehaviours.Count < 5;
    }
Exemplo n.º 2
0
 public void SetBehaviour(MoleBehaviour behaviour)
 {
     Behaviour = behaviour;
     if (_visual != null)
     {
         Destroy(_visual);
     }
     _visual = Instantiate(behaviour.Visual, transform);
 }
        public void DifficultyChangesTestScriptSimplePasses()
        {
            MoleBehaviour Mole  = mole.AddComponent <MoleBehaviour>();
            ScoreUpdate   Score = score.AddComponent <ScoreUpdate>();

            Score.increase(20000);
            Mole.UpdateDifficulty();
            Assert.AreEqual(speed, Mole.speed);
            Score.setScoreValue(0);
        }
Exemplo n.º 4
0
    public void EndExpedition()
    {
        // Remove mole behaviour 1
        MoleBehaviour launchedMole = moleBehaviours.First(behaviour => behaviour.linePosition == 1);

        moleBehaviours.Remove(launchedMole);
        Destroy(launchedMole.gameObject);

        // Advance all other ones
        foreach (MoleBehaviour moleBehaviour in moleBehaviours)
        {
            moleBehaviour.linePosition--;
        }

        recruitButton.interactable = moleBehaviours.Count < 5;
    }
Exemplo n.º 5
0
 void Spawn()
 {
     if (!hasMole && GameManager.instance.countDownDone)
     {
         int        idx  = CalculateRarity();
         GameObject mole =
             Instantiate(moles[idx],
                         this.transform.position,
                         Quaternion.identity) as
             GameObject;
         MoleBehaviour moleB = mole.GetComponent <MoleBehaviour>();
         moleB.myParent = this.gameObject;
         moleB.score    = moleB.score * GameManager.level;
         hasMole        = true;
     }
     Invoke("Spawn", Random.Range(0f, 7f));
 }
Exemplo n.º 6
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.tag == "Mole")
                {
                    Instantiate(fx_particles, hit.point, Quaternion.identity);

                    MoleBehaviour mole = hit.collider.gameObject.GetComponent <MoleBehaviour>();
                    mole.SwitchCollider(0);
                    mole.anim.SetTrigger("hit");
                }
            }
        }
    }
Exemplo n.º 7
0
    public IEnumerator FinalAnimation(GameObject[] moles)
    {
        mainCamera = GameObject.FindWithTag("MainCamera");
        float startAngle = mainCamera.transform.rotation.eulerAngles.x;
        float finalAngle = startAngle - cameraRotationAngle;

        mainCamera.Tween(mainCamera.GetHashCode().ToString(), startAngle, finalAngle, cameraRotationTime, TweenScaleFunctions.CubicEaseInOut,
                         (t) =>
        {
            Vector3 v = mainCamera.transform.rotation.eulerAngles;
            v.x       = t.CurrentValue;
            mainCamera.transform.rotation = Quaternion.Euler(v);
        },
                         (t) =>
        {
        });

        for (int i = 0; i < moles.Length; i++)
        {
            MoleBehaviour mb = moles[i].GetComponentInChildren <MoleBehaviour>();
            //mb.ResetMole();
            mb.gameObject.GetComponentInChildren <ParticleSystem>().Play();
            float startY = mb.gameObject.transform.localPosition.y;
            float finalY = startY + moleDistance;
            moles[i].Tween(i, startY, finalY, moleTime, TweenScaleFunctions.CubicEaseInOut,
                           (t) =>
            {
                Vector3 v = mb.gameObject.transform.localPosition;
                v.y       = t.CurrentValue;
                mb.gameObject.transform.localPosition = v;
            },
                           (t) =>
            {
            });
        }

        yield return(new WaitForSeconds(3f));

        isDone = true;
    }
Exemplo n.º 8
0
 // Use this for initialization
 void Start()
 {
     incomingObject = false;
     mb             = GameObject.FindGameObjectWithTag("Enemy").GetComponent <MoleBehaviour>();
 }