コード例 #1
0
    private void OnCollisionEnter(Collision collision)
    {
        HaggisInteractable iteractable = collision.gameObject.GetComponent <HaggisInteractable>();

        if (iteractable)
        {
            if (iteractable.type == HaggisInteractable.InteractableType.Wall)

            {
                // reflect haggis off object.
                if (collision.contacts.Length > 0)
                {
                    ContactPoint contact = collision.contacts[0];
                    BounceOff(contact.point, contact.normal);
                }
            }
            else if (iteractable.type == HaggisInteractable.InteractableType.Haggis)
            {
                if (collision.contacts.Length > 0)
                {
                    switch (behaviour.currentAction)
                    {
                    case HaggisBehaviour.Action.Walking:
                    case HaggisBehaviour.Action.Hop:
                    case HaggisBehaviour.Action.Leaping:
                        ReverseDirection();
                        break;
                    }
                }
            }
        }
    }
コード例 #2
0
        public WorldAhead(Vector3 lookAheadVector, RaycastHit hit)
        {
            this.position = hit.point;
            this.normal   = hit.normal;
            this.other    = hit.collider;
            HaggisInteractable interactable = hit.collider.GetComponent <HaggisInteractable>();

            if (interactable)
            {
                switch (interactable.type)
                {
                case HaggisInteractable.InteractableType.Ground:
                    this.type = HaggisInteractable.InteractableType.Ground;
                    break;

                case HaggisInteractable.InteractableType.Wall:
                    this.type = HaggisInteractable.InteractableType.Wall;
                    break;

                case HaggisInteractable.InteractableType.Hop:
                    this.type = HaggisInteractable.InteractableType.Hop;
                    break;

                default:
                    this.type = HaggisInteractable.InteractableType.None;
                    break;
                }
            }
            else
            {
                this.type = HaggisInteractable.InteractableType.None;
            }
            this.isHit           = true;
            this.lookAheadVector = lookAheadVector;
        }
コード例 #3
0
    private void OnCollisionExit(Collision collision)
    {
        HaggisInteractable interactable = collision.gameObject.GetComponent <HaggisInteractable>();

        if (interactable)
        {
            if (interactable.type == HaggisInteractable.InteractableType.Ground)
            {
                grounded = false;
            }
        }
    }
コード例 #4
0
    private void OnCollisionStay(Collision collision)
    {
        HaggisInteractable interactable = collision.gameObject.GetComponent <HaggisInteractable>();

        if (interactable)
        {
            if (interactable.type == HaggisInteractable.InteractableType.Ground && !DoingSomething())
            {
                if (Vector3.Dot(rigidBody.velocity, Vector3.up) < 0.001f)
                {
                    SetCurrentAction(Action.Walking);
                }
            }
            interactable.DoStepOn(this);
        }
    }
コード例 #5
0
    private void OnCollisionEnter(Collision collision)
    {
        HaggisInteractable interactable = collision.gameObject.GetComponent <HaggisInteractable>();

        if (interactable)
        {
            if (interactable.type == HaggisInteractable.InteractableType.Ground && !DoingSomething())
            {
                if (currentAction == Action.FastFalling)
                {
                    SetCurrentAction(Action.Exploding);
                }
                else
                {
                    SetCurrentAction(Action.Walking);
                }
            }
            else if (interactable.type == HaggisInteractable.InteractableType.Hop)
            {
                // attempt to hop over or onto the object.
                SetCurrentAction(Action.Hop);
            }
        }
    }