示例#1
0
    void Update()
    {
        // if event is set we have a win/lose conditions
        if (evt != null)
        {
            float step = 0.5f * Time.deltaTime;

            if (evt.collision_event_type == TriggerConditionRx.CollisionEventType.LOSE)
            {
                Vector3 sc_c = evt.player.transform.localScale;
                sc_c.Scale(sc);
                evt.player.transform.localScale = sc_c;
            }

            evt.player.attachedRigidbody.velocity.Set(0f, 0f);
            evt.player.attachedRigidbody.bodyType = RigidbodyType2D.Static;
            evt.player.transform.position         =
                Vector2.MoveTowards(
                    evt.player.transform.position,
                    evt.trigger.transform.position,
                    step
                    );
            //terminating condition
            if (EqualPositions(
                    evt.player.transform.position,
                    evt.trigger.transform.position))
            {
                //delegate to post collision function
                evt.player.GetComponentInParent <PlayerActions> ()
                .HandleCollisionEvent(evt.collision_event_type);

                evt = null;
            }
        }
    }
示例#2
0
    public void OnCollisionEventArgs(TriggerConditionRx.CollisionEventArgs args)
    {
        switch (args.collision_event_type)
        {
        case TriggerConditionRx.CollisionEventType.WIN:
            Debug.Log("Win");
            if (GlobalVariables.variablesRx.mode.Value == Global.Enumerations.GameMode.SCAVENGER && GlobalVariables.variablesRx.coins.Value > 0)
            {
                return;
            }
            evt = args;
            break;

        case TriggerConditionRx.CollisionEventType.LOSE:
            Debug.Log("Lose");
            evt = args;
            break;

        case TriggerConditionRx.CollisionEventType.POWERUP:
            Debug.Log("Coin");
            Destroy(args.trigger.gameObject);
            GlobalVariables.variablesRx.coins.Value--;
            break;

        default:
            Debug.Log("Unknown Event Caught " + args.collision_event_type);
            break;
        }
    }