예제 #1
0
    void LateUpdate()
    {
        if (transform.parent.localScale.x > maxRadius)
        {
            Destroy(gameObject);
        }

        Collider2D[] hitCols = Physics2D.OverlapCircleAll((Vector2)transform.position + col.offset, col.radius * transform.lossyScale.x, ~(1 << 0));
        foreach (Collider2D hitCol in hitCols)
        {
            //check if platform is interactable with this ability
            DynamicPlatformController platform = hitCol.GetComponent <DynamicPlatformController>();

            if (platform == null)
            {
                continue;
            }

            bool isInteractable = false;
            isInteractable = emotion == Emotion.Anger && (platform._type == "Shove" || platform._type == "Universal") ? true : isInteractable;
            isInteractable = emotion == Emotion.Joy && (platform._type == "Float" || platform._type == "Universal") ? true : isInteractable;
            isInteractable = emotion == Emotion.Sadness && platform._affectedBySlow ? true : isInteractable;

            //apply effect
            if (!hitColliders.Contains(hitCol) && isInteractable)
            {
                hitColliders.Add(hitCol);

                Vector3    point  = hitCol.ClosestPoint(transform.position);
                GameObject effect = Instantiate(effectPrefab, point, Quaternion.identity, hitCol.transform);
                effect.GetComponent <CollisionEffect>().emotion = emotion;
                effect.transform.up = (transform.position - point).normalized;
            }
        }

        if (transform.parent.localScale.x == maxRadius)
        {
            Destroy(gameObject);
        }
    }
예제 #2
0
    private void Start()
    {
        pXPos = transform.position.x;

        dynamicScript = GetComponent <DynamicPlatformController>();
    }
예제 #3
0
 private void OnValidate()
 {
     animator           = GetComponent <Animator>();
     platformController = GetComponent <DynamicPlatformController>();
 }
예제 #4
0
    void OnCollisionStay2D(Collision2D coll)
    {
        // Case when PJ is on a platform
        if (coll.gameObject.tag == "DynamicPlatform" && platform == null) {
            platform = coll.gameObject.GetComponent<DynamicPlatformController> ();
        }

        if (platform != null) {
            transform.Translate(Vector3.right * rotation * platform.horizontalSpeed * platform.horizontalDirection * Time.deltaTime);
            transform.Translate(Vector3.up * rotation * platform.verticalSpeed * platform.verticalDirection * Time.deltaTime);
        }
    }
예제 #5
0
 void OnCollisionExit2D(Collision2D coll)
 {
     // Case when PJ is on a platform
     if (coll.gameObject.tag == "DynamicPlatform") {
         platform = null;
     }
 }