Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (gameFinished == false)
        {
            elapsedTime += Time.deltaTime;
            // si se toco el collider
            if (Input.GetMouseButtonDown(0))
            {
                Vector3           wp   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                CapsuleCollider2D coll = TreeState.GetComponent <CapsuleCollider2D>();

                if (coll.OverlapPoint(wp))
                {
                    Debug.Log(healthPoints);
                    hits        += 1;
                    healthPoints = healthPoints - cutDamage;
                    source.PlayOneShot(cutSound, 1f);
                    anim.Play("cutDown");
                    anim.SetInteger("hp", healthPoints);
                    if (healthPoints == 0)
                    {
                        StartCoroutine(Delay());

                        //Invoke("GoBackToMenu", 4f);
                        coll         = null;
                        gameFinished = true;
                        Debug.Log(elapsedTime);
                        gameObject.GetComponent <NetMan>().GameOver();
                    }
                    UpdateScoreText();
                }
            }
        }
        elapsedTime -= duration;
    }
Beispiel #2
0
 void MouseEvent()
 {
     if (!invincible && inRange && Input.GetMouseButtonDown(0))
     {
         //Debug.Log(self.InRange);
         if (hitArea.OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)))
         {
             if (!GameSystem.stop)
             {
                 damaged = true;
                 StartCoroutine("DamageEffects");
                 Damage(miko.KamiAttack);
                 rb.velocity = Vector2.zero;
                 Debug.Log(HP);
                 if (hp <= 0)
                 {
                     stun      = true;
                     sr.sprite = s[(int)State.Stun];
                     ActiveStunEffect(true);
                     StartCoroutine("Revivals");
                 }
             }
         }
     }
 }
Beispiel #3
0
 void MouseEvent()
 {
     if (!invincible && inRange && Input.GetMouseButtonDown(0))
     {
         //Debug.Log(self.InRange);
         if (hitArea.OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)))
         {
             if (!GameSystem.stop && hp > 0)
             {
                 StartCoroutine("DamageEffects");
                 Damage(miko.KamiAttack);
                 Debug.Log(hp);
                 if (!stun && hp <= 0 && !stumble)
                 {
                     if (cc.direction != CapsuleDirection2D.Horizontal)
                     {
                         ChangeTriggerDir(true);
                     }
                     target      = null;
                     rb.velocity = Vector3.zero;
                     stun        = true;
                     ActiveStunEffect(true);
                     sr.sprite         = stunS;
                     _animator.enabled = false;
                     StartCoroutine("Revivals");
                 }
             }
         }
     }
 }
Beispiel #4
0
    bool checkTouch(Vector3 pos)
    {
        Vector3           wp       = Camera.main.ScreenToWorldPoint(pos);
        Vector2           touchPos = new Vector2(wp.x, wp.y);
        CapsuleCollider2D collider = GetComponent <CapsuleCollider2D>();

        return(collider.OverlapPoint(touchPos));
    }
Beispiel #5
0
 void SleepMode()
 {
     if (Input.GetButtonDown("Fire1") && m_CapsuleCollider.OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)))
     {
         State = EnemyState.PATROL;
     }
     else if (m_WakeningTarget != null && Vector2.Distance(m_WakeningTarget.transform.position, this.transform.position) <= m_DistanceTolerance)
     {
         m_PatrolSpeed = 8f;
         State         = EnemyState.PATROL;
     }
 }
Beispiel #6
0
 // Update is called once per frame
 void Update()
 {
     //Debug.Log(self.InRange);
     if (!self.Invincible)
     {
         if (self.InRange && Input.GetMouseButtonDown(0))
         {
             //Debug.Log(self.InRange);
             if (cc.OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)))
             {
                 MouseEvent();
             }
         }
     }
 }
Beispiel #7
0
    void Update()
    {
        if (gameFinished == false)
        {
            elapsedTime += Time.deltaTime;
            Debug.Log(elapsedTime);

            if (Input.GetMouseButtonDown(0))
            {
                Debug.Log("clickeando");
                Vector3           wp       = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                CapsuleCollider2D colaider = krabsState.GetComponent <CapsuleCollider2D>();

                int auxIndexX = Random.Range(0, 4);
                int auxIndexY = Random.Range(0, 4);

                if (colaider.OverlapPoint(wp))
                {
                    anim.Play("hitKrab");
                    Debug.Log(elapsedTime);
                    hitTimes += 1;
                    source.PlayOneShot(damageSound, 1f);
                    anim.Play("Krab");
                    elapsedTimeInt = (int)elapsedTime;
                    if (elapsedTimeInt == timeToFinish)
                    {
                        colaider     = null;
                        gameFinished = true;
                        StartCoroutine(delay());
                        gameObject.GetComponent <NetMan>().GameOver();
                    }
                    UpdateScoreText();
                    transform.position = new Vector3(positionX[auxIndexX], positionY[auxIndexY], transform.position.z);
                }
            }
        }
    }
Beispiel #8
0
    // Update is called once per frame
    void Update()
    {
        time += Time.deltaTime;

        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            setTool(1);
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            setTool(2);
        }
        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            setTool(3);
        }

        //print(tankanim.GetCurrentAnimatorStateInfo(0).is);
        if (tankanim.GetCurrentAnimatorStateInfo(0).IsName("firefire"))
        {
            //tankpart.enableEmission = true; // no worky no clue why
            print("not good tnaky");
            life -= Time.deltaTime * 20;
        }

        if (time > (17340 / 60))
        {
            print("win");
            SceneManager.LoadScene("winner", LoadSceneMode.Single);
        }
        if (water < 0.01)
        {
            print("lose");
            SceneManager.LoadScene("loser", LoadSceneMode.Single);
        }
        if (life < 0)
        {
            SceneManager.LoadScene("loser", LoadSceneMode.Single);
        }

        Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        //print(water);
        water -= Time.deltaTime * 0.1; // much faster if sun angry

        if (sunlol.GetCurrentAnimatorStateInfo(0).IsName("angry"))
        {
            water -= Time.deltaTime * 0.4;
        }

        if (tool == 1)
        {
            if (Input.GetMouseButton(0))
            {
                if (mousePosition.x > -2 && mousePosition.x < 7)
                {
                    water += Time.deltaTime * 0.7;
                }
            }

            partgisk.enableEmission = Input.GetMouseButton(0);
            // ultra unclean yuck
        }
        if (tool == 2)
        {
            if (Input.GetMouseButtonDown(0))
            {
                Vector2 argh = Camera.main.ScreenToWorldPoint(Input.mousePosition);

                GameObject a = GameObject.Find("mypref");

                if (a != null)
                {
                    CapsuleCollider2D col = a.GetComponent <CapsuleCollider2D>();

                    if (col.OverlapPoint(argh))
                    {
                        print("hmm");

                        a.SendMessage("endit");
                    }
                }
            }
        }
        if (tool == 3)
        {
            if (Input.GetMouseButtonDown(0))
            {
                Vector2 argh = Camera.main.ScreenToWorldPoint(Input.mousePosition);

                if (tankcol.OverlapPoint(argh))
                {
                    batparts.Emit(200);
                    tanklives -= 1;
                    if (tanklives == 0)
                    {
                        tankanim.Play("retreat");
                    }
                }
            }
        }
        //print(life);
        lbar.transform.localScale = new Vector3((float)(2 * (life / 100)), 1.4f, 1);

        water = Mathf.Clamp((float)water, 0, 10);
        bar.transform.localScale = new Vector3(0.2f, (float)water, 0);
    }