Example #1
0
    // Update is called once per frame
    void Update()
    {
        isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

        if (isGrounded && velocity.y < 0)
        {
            velocity.y = -50f;
        }

        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");

        Vector3 move = transform.right * x + transform.forward * z;

        controller.Move(move * speed * Time.deltaTime);

        if (Input.GetButtonDown("Jump") && isGrounded)
        {
            velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
        }

        velocity.y += gravity * Time.deltaTime;

        controller.Move(velocity * Time.deltaTime);

        if (Input.GetKeyDown(KeyCode.Y))
        {
            PopUpSystem pop = GameObject.FindGameObjectWithTag("PopUp System").GetComponent <PopUpSystem>(); //品臻加的
            pop.PopUp(popUp);                                                                                //品臻加的
        }
    }
Example #2
0
 // Update is called once per frame
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (collision.name == "MainChar" && bridge1Built == false)
     {
         if (GameManager.stone >= 2 && GameManager.wood >= 3)
         {
             if (Input.GetKey("e"))
             {
                 gameObject.GetComponent <BoxCollider2D>().enabled = false;
                 print("You have collided and pressed 'e'");
                 bridge1Built       = true;
                 GameManager.wood  -= 4;
                 GameManager.stone -= 3;
                 animator.SetBool("bridge1", true);
             }
         }
         else
         {
             if (Input.GetKey("e"))
             {
                 PopUpSystem pop = GameObject.Find("GameManager").GetComponent <PopUpSystem>();
                 pop.PopUp(popUp);
                 print("You need more resources");
             }
         }
     }
     if (bridge1Built)
     {
         print("A bridge piece has been built");
     }
 }
Example #3
0
    private void PickUp()
    {
        switch (gameObject.tag)
        {
        case "Speed Powerup":
            _playerController.increasePlayerSpeed(.2f);
            Destroy(gameObject);
            _popUpSystem.PopUp("Sports drink equipped - Increased movement speed by 20%");
            break;

        case "Fastball Powerup":
            _playerController.increaseProjectileSpeed(10);
            Destroy(gameObject);
            _popUpSystem.PopUp("Fastball equipped - Increased projectile speed");
            break;
        }
    }
Example #4
0
 public virtual void boundaryUI()
 {
     Thisreg = "Asia and Pacific_Boundary";
     if (lastreg != Thisreg)
     {
         //Debug.Log("Asia and Pacific_Boundary");
         PopUpSystem pop = GameObject.FindGameObjectWithTag("GameManager").GetComponent <PopUpSystem>();
         pop.PopUp("<size=10>" + "Asia and Pacific" + "</size>");
         lastreg = Thisreg;
         // StartCoroutine(PopUpSystem.DelayFuc(() => { pop.Close(); }, 3.0f));
     }
 }
Example #5
0
 public virtual void boundaryUI()
 {
     Thisreg = "Middle East and North Africa";
     if (lastreg != Thisreg)
     {
         //Debug.Log("Middle East and North Africa");
         PopUpSystem pop = GameObject.FindGameObjectWithTag("GameManager").GetComponent <PopUpSystem>();
         pop.PopUp("<size=10>" + "Middle East \n and North Africa" + "</size>");
         lastreg = Thisreg;
         //StartCoroutine(PopUpSystem.DelayFuc(() => { pop.Close(); }, 3.0f));
     }
 }
Example #6
0
    // Update is called once per frame
    void Update()
    {
        if (state == State.Idle)
        {
            image.sprite = idle[0];
            if (Input.GetKeyDown(KeyCode.S))
            {
                animTimer = 0;
                state     = State.In;
                swingCounter++;
            }
        }

        if (state == State.In)
        {
            if (animTimer < frameCount - 1)
            {
                animTimer   += Time.smoothDeltaTime * speed;
                image.sprite = inAnim[Mathf.FloorToInt(animTimer)];
            }
            else if (Input.GetKeyDown(KeyCode.W))
            {
                animTimer = 0;
                state     = State.Out;
            }
        }
        if (state == State.Out)
        {
            if (animTimer < frameCount - 1)
            {
                animTimer   += Time.smoothDeltaTime * speed;
                image.sprite = outAnim[Mathf.FloorToInt(animTimer)];
            }
            else if (Input.GetKeyDown(KeyCode.S))
            {
                animTimer = 0;
                state     = State.In;
                swingCounter++;
            }
        }
        if (swingCounter >= 3 && frameCount - 1 < animTimer)
        {
            swingCounter = 0;
            PopUpSystem pop = GameObject.Find("GameManager").GetComponent <PopUpSystem>();
            pop.PopUp(popUp);
            this.gameObject.SetActive(false);
            GameManager.stone++;
            playerMovement.freezePlayer = false;
            state = State.Idle;
        }
    }
Example #7
0
    // Start is called before the first frame update
    void Start()
    {
        PopUpSystem pop = GameObject.FindGameObjectWithTag("GameManager").GetComponent <PopUpSystem>();

        pop.PopUp(popUp);
    }