FindAssociatedLevel() public static method

public static FindAssociatedLevel ( Transform current ) : Level,
current Transform
return Level,
Exemplo n.º 1
0
    void Awake()
    {
        var camGO = GameObject.Find("MainCamera");

        if (camGO)
        {
            transform.rotation = camGO.transform.rotation;
        }

        Walker = GetComponent <RoadWalker>();
        sprite = GetComponent <tk2dAnimatedSprite>();

        Walker.RoadToWalk = GameUtils.FindAssociatedLevel(transform).transform.Find("Road").GetComponent <Spline>();

        Walker.Step();
        lastPosition = transform.position;
        Walker.Step();
        UpdateDirection();

        transform.Find("RotatedCollider").gameObject.layer = LayerMask.NameToLayer("Player");

        if (MainGameView.Instance)
        {
            Walker.Stop();
            MainGameView.Instance.m_OnSceneReadyCallback += Walker.Resume;
        }
    }
Exemplo n.º 2
0
    void Start()
    {
        transform.localRotation = Quaternion.identity;

        sprite = GetComponent <tk2dAnimatedSprite>();
        parent = transform.parent.GetComponent <Malisse>();
        Walker = GetComponent <RoadWalker>();

        Walker.RoadToWalk = GameUtils.FindAssociatedLevel(transform).transform.Find("Road").GetComponent <Spline>();

        Walker.Stop();
    }
Exemplo n.º 3
0
    private void GrabObstacle()
    {
        m_Asset.spriteId = m_Asset.GetSpriteIdByName(m_HandGrabbedAssetName);

        if (m_IsGrabbing)
        {
            return;
        }

        m_IsGrabbing = true;

        if (m_HoveringObstacleHandle != null && !m_HoveringObstacleHandle.IsGrabbed && m_GrabbedObstacleJoin == null)
        {
            AudioManager.Instance.PlaySFX(m_SFXGrab);
            AudioManager.Instance.PlayLoopingSFX(m_SFXHoldGrab, 0.4f);

            // Find hit point.
            Vector3      handHitPosition = transform.position - (CameraController.Instance.m_HandCamera.transform.TransformDirection(Vector3.forward) * 2000.0f);
            RaycastHit[] hits            = Physics.SphereCastAll(handHitPosition, (collider as CapsuleCollider).radius, CameraController.Instance.m_HandCamera.transform.TransformDirection(Vector3.forward));

            Vector3 hitPoint = transform.position;
            bool    isHit    = false;
            if (hits.Length > 0)
            {
                foreach (RaycastHit hit in hits)
                {
                    Obstacle obstacle = hit.collider.gameObject.GetComponent <Obstacle>();
                    if (obstacle != null)
                    {
                        hitPoint = hit.point;
                        isHit    = true;
                        break;
                    }
                }
            }

            if (isHit)
            {
                m_GrabbedObstacleHandle = m_HoveringObstacleHandle;
                m_GrabbedObstacleHandle.OnGrabbed();

                GameObject joint = new GameObject("Join");
                joint.transform.position = hitPoint;
                joint.transform.parent   = transform;

                GameUtils.FindAssociatedLevel(transform).m_Malisse.RevertWalkableCollider(m_HoveringObstacleHandle.m_Obstacle.collider);

                m_GrabbedObstacleJoin = joint.AddComponent <HingeJoint>();
                m_GrabbedObstacleJoin.rigidbody.useGravity  = false;
                m_GrabbedObstacleJoin.rigidbody.constraints = RigidbodyConstraints.FreezePosition | RigidbodyConstraints.FreezeRotation;
                m_GrabbedObstacleJoin.connectedBody         = m_HoveringObstacleHandle.m_Obstacle.rigidbody;

                // Move hand.
                m_GoalHeight = GRABBED_OFFSET;
                StopCoroutine("RaiseHand");
                StartCoroutine("RaiseHand");
            }
        }
        else
        {
            AudioManager.Instance.PlaySFX(m_SFXCantGrab);
        }
    }