Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        // 如果被控制,则玩家操控
        if (controlled)
        {
            charmRenderer.enabled = true;
            beController.ControlMove();
            // 如果有可以交互的道具
            // 则可以交互
        }
        else
        {
            charmRenderer.enabled = false;
            if (!onlyStay)
            {
                // 如果不被控制,则自己行动
                if (staying)
                {
                    if (staytimer >= stayTime)
                    {
                        transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localPosition.z);
                        staying = false;
                    }
                    else
                    {
                        staytimer += Time.deltaTime;
                        return;
                    }
                }

                if (transform.localScale.x > 0)
                {
                    if (transform.position.x < rightPatrolPointx)
                    {
                        beController.MoveRight();
                    }
                    else
                    {
                        staying   = true;
                        staytimer = 0;
                        beController.Stop();
                    }
                }
                else
                {
                    if (transform.position.x > leftPatrolPointx)
                    {
                        beController.MoveLeft();
                    }
                    else
                    {
                        staying   = true;
                        staytimer = 0;
                        beController.Stop();
                    }
                }
            }
        }
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        if (controlled)
        {
            playerMove.canMove = true;
            playerMove.ControlMove();
        }
        else
        {
            playerMove.canMove = false;
        }

        var hit = Physics2D.Raycast(face.position,
                                    new Vector2(Mathf.Cos(77.71f * Mathf.Deg2Rad), Mathf.Sin(77.71f * Mathf.Deg2Rad)),
                                    Mathf.Infinity,
                                    LayerMask.GetMask("Floor") | LayerMask.GetMask("Hole") | LayerMask.GetMask("Shelter"));

        if (hit.collider == null || LayerMask.LayerToName(hit.transform.gameObject.layer) == "Hole")
        {
            gameManager.GameOver();
            SFXUtils.PlayOnce(SFXUtils.Clips.Burnout, 1.0f);
        }
    }