Beispiel #1
0
    public virtual void Awake()
    {
        MyTr = transform;

        if (MyTr.parent == null)
        {
            MyTr.SetParent(new GameObject("Group").transform, true);
        }
        else if (MyTr.parent.parent != null)
        {
            Debug.LogWarning("PVC item shouldn't be more than one-deep in the hierarchy");
        }
    }
Beispiel #2
0
    public virtual void DeselectMe()
    {
        for (int i = 0; i < MyTr.childCount; ++i)
        {
            if (!ChildrenToIgnore.Contains(MyTr.GetChild(i)))
            {
                MyTr.GetChild(i).gameObject.SetActive(false);
            }
        }

        if (MyImg != null)
        {
            MyImg.color = DeselectedColor;
        }
        IsSelected = false;
    }
    void Update()
    {
        //Input.

        MyTr.Rotate(new Vector3(0.0f, 1.0f, 0.0f), TurnInput.x, Space.World);
        MyTr.Rotate(MyTr.right, TurnInput.y, Space.World);

        Vector3 moveDelta = (MoveInput.x * MyTr.right) +
                            (MoveInput.y * MakeHorz(MyTr.forward));

        MyContr.Move(moveDelta * MoveSpeed * Time.deltaTime);

        if (CanTakePhotos && IsShooting)
        {
            StartCoroutine(TakePhotoCoroutine());
        }


        //Gravity.

        GravitySpeed -= Time.deltaTime * Gravity;

        Vector3        gravityDir = new Vector3(0.0f, GravitySpeed * Time.deltaTime, 0.0f);
        CollisionFlags hitResult  = MyContr.Move(gravityDir);

        if ((hitResult & CollisionFlags.Below) != CollisionFlags.None)
        {
            GravitySpeed = 0.0f;

            //Jumping.
            if (IsJumping)
            {
                GravitySpeed = JumpSpeed;
                MultiAudioListener.Instance.PlayClip(JumpSound, Vector3.zero);
            }
        }
    }