コード例 #1
0
ファイル: Rhino.cs プロジェクト: WladmirJunior/UnityProjects
    public void Run()
    {
        anim.SetBool("Preparing", false);
        state = RhinoState.RUN;

        if (Player.transform.position.x < this.transform.position.x)
        {
            transform.localScale = new Vector3(startScale.x, startScale.y, startScale.z);
            rigidbody2D.velocity = new Vector2(-20, 0);
        }
        else
        {
            transform.localScale = new Vector3(-startScale.x, startScale.y, startScale.z);
            rigidbody2D.velocity = new Vector2(20, 0);
        }
    }
コード例 #2
0
ファイル: Rhino.cs プロジェクト: WladmirJunior/UnityProjects
    public void Preparing()
    {
        anim.SetBool("Dizzy", false);

        print("Vezes executadas");
        rigidbody2D.velocity = new Vector2(0, 0);
        state = RhinoState.PREPARING;

        if (Player.transform.position.x < this.transform.position.x)
        {
            transform.localScale = new Vector3(startScale.x, startScale.y, startScale.z);
        }
        else
        {
            transform.localScale = new Vector3(-startScale.x, startScale.y, startScale.z);
        }

        anim.SetBool("Preparing", true);

        Invoke("Run", Random.Range(2.5F, 4F));
    }
コード例 #3
0
ファイル: Rhino.cs プロジェクト: WladmirJunior/UnityProjects
    void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Trigger")
        {
            state = RhinoState.DIZZY;
            anim.SetBool("Dizzy", true);
            Dizzy();
            //Invoke("Preparing", 4F);
        }

        if (collision.gameObject.tag == "Player")
        {

            collision.gameObject.GetComponent<Player>().Die();
            GameObject.Find("Level").GetComponent<Level>().MoveCamera = false;
            Invoke("Restart", 2f);
        }
    }
コード例 #4
0
ファイル: Rhino.cs プロジェクト: WladmirJunior/UnityProjects
    void Update()
    {
        anim.SetFloat("Speed", Mathf.Abs(rigidbody2D.velocity.x));

        if (state == RhinoState.RUN && (Mathf.Abs(rigidbody2D.velocity.x) >= 0 && Mathf.Abs(rigidbody2D.velocity.x) < 10))
        {
            state = RhinoState.BRAKING;
            Invoke("Preparing", 0.5F);
        }

        if (state == RhinoState.RUN)
        {
            if (rigidbody2D.velocity.x < 0 && Player.transform.position.x > this.transform.position.x)
            {
                rigidbody2D.velocity = new Vector2(-10, 0);
            }
            else if (rigidbody2D.velocity.x > 0 && Player.transform.position.x + 5 < this.transform.position.x)
            {
                rigidbody2D.velocity = new Vector2(10, 0);
            }
        }
    }
コード例 #5
0
ファイル: Rhino.cs プロジェクト: WladmirJunior/UnityProjects
 void Start()
 {
     state = RhinoState.IDLE;
     startScale = transform.localScale;
     anim = GetComponent<Animator>();
     Player = GameObject.Find("Player");
     hit = 0;
 }