コード例 #1
0
    // Use this for initialization
    void Start()
    {
        Instantiate(Resources.Load("Characters/" + ZPlayerPrefs.GetString("Player")), transform.position, Quaternion.identity);
        // Don't let screen turn off
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        ss = this.GetComponent("StartScreen") as StartScreen;
        cs = GameObject.FindObjectOfType <CatScript>();
    }
コード例 #2
0
    void Start()
    {
        cat = GetComponent <CatScript>();


        catActions[(int)CatActions.Resting]   = gameObject.AddComponent <RestingActionScript>();
        catActions[(int)CatActions.Milling]   = gameObject.AddComponent <MillingActionsScript>();
        catActions[(int)CatActions.Pouncing]  = gameObject.AddComponent <PouncingActionScript>();
        catActions[(int)CatActions.Sprinting] = gameObject.AddComponent <CatVision>();
        currentAction = catActions[(int)CatActions.Milling];
    }
コード例 #3
0
ファイル: ScorePoint.cs プロジェクト: Git-Good/This-Side-Up
    void OnTriggerEnter2D(Collider2D collider)
    {
        CatScript cs = GameObject.FindObjectOfType <CatScript>();

        if (collider.tag == "Player" && cs.lose != true)
        {
            gameObject.SetActive(false);
            GameObject scoreText = GameObject.FindWithTag("ScoreText");
            scoreText.SendMessage("AddPoint");
        }
    }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        float moveZ = Input.GetAxis("Vertical") * speed * Time.deltaTime;
        float moveX = Input.GetAxis("Horizontal") * speed * Time.deltaTime;

        transform.Translate(moveX, 0, moveZ);
        if ((Input.GetButtonDown("Horizontal") || Input.GetButtonDown("Vertical")) && Time.timeScale > 0)
        {
            walkAudio.Play();
        }
        else if (!Input.GetButton("Horizontal") && !Input.GetButton("Vertical") && walkAudio.isPlaying)
        {
            walkAudio.Pause();
        }


        if (Input.GetKeyDown(KeyCode.G))
        {
            GameObject[] cucumbers = GameObject.FindGameObjectsWithTag("cucumber");
            Vector3      position  = transform.position;
            foreach (GameObject cucumber in cucumbers)
            {
                if ((cucumber.transform.position - position).sqrMagnitude < maxDistance)
                {
                    Destroy(cucumber);
                    cucumberCounter += 3;
                    cucumerText.text = "" + cucumberCounter;
                    break;
                }
            }
        }
        if (Input.GetKeyDown(KeyCode.F) && cucumberCounter > 0)
        {
            GameObject[] cats     = GameObject.FindGameObjectsWithTag("cat");
            Vector3      position = transform.position;
            foreach (GameObject cat in cats)
            {
                if ((cat.transform.position - position).sqrMagnitude < maxDistance)
                {
                    CatScript catScript = cat.GetComponent <CatScript>();
                    if (catScript.health < catScript.maxHealth)
                    {
                        catScript.health      += 1;
                        catScript.slider.value = catScript.health / catScript.maxHealth;
                        cucumberCounter--;
                        cucumerText.text = "" + cucumberCounter;
                        break;
                    }
                }
            }
        }
    }
コード例 #5
0
    void Update()
    {
        if ((Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0)) && !isJumping)
        {
            Jump();
        }

        if (isJumping && (Input.GetKey(KeyCode.Space) || Input.GetMouseButton(0)) && holdTime > 0)
        {
            rigid.velocity = Vector2.up * jumpForce;
            holdTime      -= Time.deltaTime;
        }

        if (isJumping && (Input.GetKeyUp(KeyCode.Space) || Input.GetMouseButtonUp(0)))
        {
            holdTime = 0;
        }

        //if (rigid.velocity.y >= 0) rigid.gravityScale = 1f;
        //else
        //{
        //    rigid.gravityScale = 1.25f;
        //}


        RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.up, 5, 1 << LayerMask.NameToLayer("Obstacle"));

        if (hit.collider != null)
        {
            CatScript cs = hit.transform.GetComponent <CatScript>();
            GameController.Instance.AddPoint(cs.point);
            cs.point = 0;
        }

        hit = Physics2D.Raycast(transform.position, Vector2.down, 5, 1 << LayerMask.NameToLayer("Obstacle"));

        if (hit.collider != null)
        {
            CatScript cs = hit.transform.GetComponent <CatScript>();
            GameController.Instance.AddPoint(cs.point);
            cs.point = 0;
        }


        if (isJumping && !isLanding && rigid.velocity.y < 0 && Physics2D.Raycast(transform.position, Vector2.down, 1f, 1 << LayerMask.NameToLayer("Floor")).collider != null)
        {
            isLanding = true;
            animator.SetTrigger("Land");
        }
    }
コード例 #6
0
 public void CountDown()
 {
     timerText      = gameObject.GetComponent <Text>();
     timerText.text = currentTime;
     if (startTime <= 5)
     {
         timerText.color = new Color32(240, 128, 128, 255);
     }
     if (startTime <= 0)
     {
         whistleS.PlayOneShot(whistleSound);
         CatScript cs = GameObject.FindObjectOfType <CatScript>();
         startTime = 0f;
         cs.lose   = true;
         StartCoroutine(LoseTimeTrial());
     }
 }
コード例 #7
0
 void Start()
 {
     cs = this.transform.parent.GetComponent<CatScript> ();
 }
コード例 #8
0
 void Start()
 {
     cs = GameObject.FindObjectOfType <CatScript>();
 }
コード例 #9
0
 void Start()
 {
     cs = this.transform.parent.GetComponent <CatScript> ();
 }
コード例 #10
0
ファイル: ShooterState.cs プロジェクト: matheuspb95/Pryaspime
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     Cat = animator.GetComponent <CatScript>();
     StartPattern();
 }
コード例 #11
0
ファイル: ActionScript.cs プロジェクト: ch1pch4p/gmtk2020
 public virtual void Start()
 {
     cat = GetComponent <CatScript>();
 }