Exemplo n.º 1
0
    private void OnCollisionEnter(Collision other)
    {
        BeachBall component = other.gameObject.GetComponent <BeachBall>();

        BeachBallTarget.OnTargetHit(definition, component, this);
        if (!(component != null))
        {
            return;
        }
        switch (definition.type)
        {
        case BeachBallTargetController.TargetType.Positive:
            component.EnableCollider(enable: false);
            onPositiveHit();
            break;

        case BeachBallTargetController.TargetType.Negative:
            component.EnableCollider(enable: false);
            onNegativeHit();
            break;

        case BeachBallTargetController.TargetType.Shielded:
            if (definition.blockerLevel > 0)
            {
                onShieldHit();
            }
            break;
        }
    }
    private IEnumerator hideVisibleTarget(BeachBallTarget target, float delay)
    {
        yield return(new WaitForSeconds(delay));

        target.EnableColliders(enable: false);
        animateOut(target);
    }
    private void SetRandomTargetType(BeachBallTarget target)
    {
        int num = UnityEngine.Random.Range(0, definitions.Length);
        TargetDefinition defintion = definitions[num];

        target.SetDefintion(defintion);
    }
    private IEnumerator showHiddenTarget(BeachBallTarget target, float delay)
    {
        yield return(new WaitForSeconds(delay));

        target.EnableColliders(enable: true);
        SetRandomTargetType(target);
        animateIn(target);
    }
    private void punchScale(BeachBallTarget target)
    {
        Hashtable hashtable = new Hashtable();

        hashtable.Add("amount", new Vector3(0.65f, 0.65f, 0.65f));
        hashtable.Add("time", exitDelay);
        iTween.PunchScale(target.gameObject, hashtable);
    }
    private void animateIn(BeachBallTarget target)
    {
        Hashtable hashtable = new Hashtable();

        hashtable.Add("position", target.OriginPosition);
        hashtable.Add("time", 0.5f);
        hashtable.Add("islocal", true);
        hashtable.Add("easetype", "spring");
        hashtable.Add("oncompletetarget", base.gameObject);
        hashtable.Add("oncomplete", "onAnimatedIn");
        hashtable.Add("oncompleteparams", target);
        iTween.MoveTo(target.gameObject, hashtable);
    }
    private void animateOut(BeachBallTarget target)
    {
        Hashtable hashtable = new Hashtable();

        hashtable.Add("position", target.OriginPosition - (ANIMATION_OFFSET + new Vector3(0f, target.OriginPosition.y, 0f)));
        hashtable.Add("time", 0.5f);
        hashtable.Add("islocal", true);
        hashtable.Add("easetype", "spring");
        hashtable.Add("oncompletetarget", base.gameObject);
        hashtable.Add("oncomplete", "onAnimatedOut");
        hashtable.Add("oncompleteparams", target);
        iTween.MoveTo(target.gameObject, hashtable);
    }
Exemplo n.º 8
0
    private void onHitTarget(BeachBallTarget.TargetDefinition definition, BeachBall ball, BeachBallTarget target)
    {
        if (ball == this)
        {
            switch (definition.type)
            {
            case BeachBallTargetController.TargetType.Positive:
                resetPosition(hitTarget: true);
                break;

            case BeachBallTargetController.TargetType.Negative:
                resetPosition(hitTarget: false);
                break;

            case BeachBallTargetController.TargetType.Shielded:
                break;
            }
        }
    }
 private void onAnimatedIn(BeachBallTarget target)
 {
     CoroutineRunner.Start(hideVisibleTarget(target, UnityEngine.Random.Range(minVisibleTime, maxVisibleTime)), target, "HideBeachBallTarget");
 }
 private void onAnimatedOut(BeachBallTarget target)
 {
     CoroutineRunner.Start(showHiddenTarget(target, UnityEngine.Random.Range(minVisibleTime, maxVisibleTime)), target, "ShowBeachBallTarget");
 }
    private void onTargetHit(BeachBallTarget.TargetDefinition definition, BeachBall ball, BeachBallTarget target)
    {
        switch (definition.type)
        {
        case TargetType.Positive:
            scoreTarget += definition.pointValue;
            target.ScorePopUp.InitFloatingScoreText(target.transform, definition.pointValue);
            CoroutineRunner.StopAllForOwner(target);
            CoroutineRunner.Start(hideVisibleTarget(target, exitDelay), target, "HideBeachBallTarget");
            punchScale(target);
            break;

        case TargetType.Negative:
            CoroutineRunner.StopAllForOwner(target);
            CoroutineRunner.Start(hideVisibleTarget(target, exitDelay), target, "HideBeachBallTarget");
            punchScale(target);
            break;

        case TargetType.Shielded:
            if (definition.blockerLevel == 0)
            {
                scoreTarget += definition.pointValue;
                target.ScorePopUp.InitFloatingScoreText(target.transform, definition.pointValue);
                CoroutineRunner.StopAllForOwner(target);
                CoroutineRunner.Start(hideVisibleTarget(target, exitDelay), target, "HideBeachBallTarget");
            }
            break;
        }
    }