Ejemplo n.º 1
0
    private void Awake()
    {
        var root = transform.root;

        birdPhysics     = root.GetComponentInChildren <BirdPhysics>();
        collisionSensor = root.GetComponentInChildren <CollisionSensor>();
    }
Ejemplo n.º 2
0
 public static void Start()
 {
     RuntimeObject.Init();
     RigidBody.Init();
     CollisionBody.Init();
     CollisionSensor.Init();
     TransportSurface.Init();
     CollisionMaterial.Init();
     HingeJoint.Init();
     SlidingJoint.Init();
     CylindricalJoint.Init();
     FixedJoint.Init();
     BallJoint.Init();
     AngularLimit.Init();
     LinearLimit.Init();
     AngularSpring.Init();
     LinearSpring.Init();
     SpeedControl.Init();
     PositionControl.Init();
     BreakingConstraint.Init();
     GearCoupling.Init();
     CamCoupling.Init();
     ElecCamCoupling.Init();
     PreventCollision.Init();
     ChangeMaterial.Init();
     ComponentPart.Init();
     SourceBehavior.Init();
     SinkBehavior.Init();
     GraphControl.Init();
     ExternalConnection.Init();
     SignalAdapter.Init();
     Signal.Init();
     ProxyObject.Init();
     RuntimeParameters.Init();
 }
Ejemplo n.º 3
0
    private void Awake()
    {
        birdPhysics     = transform.root.GetComponentInChildren <BirdPhysics>();
        collisionSensor = transform.root.GetComponentInChildren <CollisionSensor>();
        gameController  = GameObject.FindWithTag(Tags.GameController).GetComponent <GameController>();

        birdDeathEventChannel = GameObject.FindWithTag(Tags.GameController).GetComponent <BirdDeathEventChannel>();
    }
Ejemplo n.º 4
0
    public void OnTriggerExit(Collider other)
    {
        CollisionSensor component = other.GetComponent <CollisionSensor>();

        if (component != null)
        {
            component.UnblockBlockGrab();
        }
    }
Ejemplo n.º 5
0
    public void OnTriggerEnter(Collider other)
    {
        CollisionSensor component = other.GetComponent <CollisionSensor>();

        if (component != null)
        {
            component.BlockGrab(this);
        }
    }
Ejemplo n.º 6
0
        // Use this for initialization
        private void Awake()
        {
            collisionSensor = transform.root.GetComponentInChildren <CollisionSensor>();

            lifetime = new Stopwatch();
            lifetime.Start();

            if (speed <= 0)
            {
                throw new ArgumentException("Speed is negative or null");
            }
        }
Ejemplo n.º 7
0
 private void HandleCollision(Collision collision)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Handling Collision ");
     }
     if (collision.contacts.Length != 0)
     {
         CollisionSensor component = collision.transform.gameObject.GetComponent <CollisionSensor>();
         if (!(component == null) && component.knockdown != 0f && !component.human.grabManager.IsGrabbed(base.gameObject))
         {
             component.human.ReceiveHit(-collision.GetImpulse() / collision.rigidbody.mass * component.knockdown);
         }
     }
 }
Ejemplo n.º 8
0
    private void Awake()
    {
        this.birdPhysics            = birdPhysics ?? transform.root.GetComponentInChildren <BirdPhysics>();
        this.collisionSensor        = transform.root.GetComponentInChildren <CollisionSensor>();
        this.playerDiedEventChannel = GameObject.FindGameObjectWithTag(Tags.GameController).
                                      GetComponent <PlayerDiedEventChannel>();

        if (birdPhysics == null)
        {
            SayToLog("BirdPhysics component not found!");
        }
        if (collisionSensor == null)
        {
            SayToLog("CollisionSensor component not found!");
        }
    }
Ejemplo n.º 9
0
    private bool CanFlip(CollisionSensor sensor, Collision2D other)
    {
        if (!handle.InAir)
        {
            return(false);
        }
        Vector2 contactPoint = other.contacts[0].point;
        Vector2 center       = sensor.GetCollider().bounds.center;

//		Debug.DrawLine(contactPoint, center, Color.red, 10f);
//		Vector3 pointB = center - contactPoint;
//		float angle = Vector2.Angle(contactPoint, center);
        bool top = contactPoint.y > center.y && Mathf.Abs(handle.VerticalVelocity - 0.5f) > 0.25f;

        return(top);
    }
Ejemplo n.º 10
0
        public void SetMarathonJoints(List <MarathonJoint> marathonJoints)
        {
            MarathonJoints = marathonJoints;
            var target = FindTopMesh(MarathonJoints.FirstOrDefault()?.Joint.gameObject, null);

            if (CameraTarget != null && MarathonJoints != null)
            {
                var smoothFollow = CameraTarget.GetComponent <SmoothFollow>();
                if (smoothFollow != null)
                {
                    smoothFollow.target = target.transform;
                }
            }

            FocalPoint      = target;
            FocalRidgedBody = FocalPoint.GetComponent <Rigidbody>();
            var qlen = MarathonJoints.Count + 3;

            qpos             = Enumerable.Range(0, qlen).Select(x => 0f).ToList();
            qglobpos         = Enumerable.Range(0, qlen).Select(x => 0f).ToList();
            qvel             = Enumerable.Range(0, qlen).Select(x => 0f).ToList();
            JointAngles      = Enumerable.Range(0, MarathonJoints.Count).Select(x => 0f).ToList();
            JointVelocity    = Enumerable.Range(0, MarathonJoints.Count).Select(x => 0f).ToList();
            _baseTargetPairs = MarathonJoints
                               .Select(x => new System.Tuple <ConfigurableJoint, Transform>(x.TrueBase, x.TrueTarget))
                               //.Distinct()
                               .ToList();
            JointRotations         = Enumerable.Range(0, _baseTargetPairs.Count).Select(x => Quaternion.identity).ToList();
            JointAngularVelocities = Enumerable.Range(0, _baseTargetPairs.Count).Select(x => Vector3.zero).ToList();

            for (int i = 0; i < MarathonJoints.Count; i++)
            {
                configurableJoints.Add(MarathonJoints[i].Joint.GetComponent <ConfigurableJoint>());
                if (configurableJoints[i].gameObject.name.Contains("ankle") ||
                    configurableJoints[i].gameObject.name.Contains("tibia"))
                {
                    CollisionSensor sensor = configurableJoints[i].gameObject.AddComponent <CollisionSensor>();
                    collisionSensors.Add(sensor);
                }
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Whether or not a box will fit in a position one space to the right of where it
 /// currently is.
 /// </summary>
 /// <returns>Returns true if the box would fit in the space directly to its right.</returns>
 public bool FitsRight(out Collider2D[] hits) => CollisionSensor.FitsRight(playerCollider.bounds.center, playerCollider.bounds.size, out hits);
Ejemplo n.º 12
0
 /// <summary>
 /// Whether or not the top right of the collider is close to a wall.
 /// </summary>
 /// <returns>True if the collider's top right corner is by a wall. False otherwise.</returns>
 public float TopDistanceToRightWall() => CollisionSensor.TopDistanceToRightWall(playerCollider.bounds.center, playerCollider.bounds.extents);
Ejemplo n.º 13
0
 public void Connect(string strName, out CollisionSensor item)
 {
     item = RuntimeObject.FromPtr(ExGetProperty(this.m_pSelf, strName, 4, 0x32c8)) as CollisionSensor;
 }
Ejemplo n.º 14
0
 /// <summary>
 /// How far the object is from the closest ceiling.
 /// </summary>
 /// <returns>The distance between the object and the closest ceiling.</returns>
 public float DistanceToCeiling() => CollisionSensor.DistanceToCeiling(playerCollider.bounds.center, playerCollider.bounds.extents);
Ejemplo n.º 15
0
 /// <summary>
 /// Whether or not the bottom left of the collider is close to a wall.
 /// </summary>
 /// <returns>True if the collider's bottom left corner is by a wall. False otherwise.</returns>
 public float BottomDistanceToLeftWall() => CollisionSensor.BottomDistanceToLeftWall(playerCollider.bounds.center, playerCollider.bounds.extents);
Ejemplo n.º 16
0
 /// <summary>
 /// Whether or not the player is touching a right-hand wall.
 /// </summary>
 public bool IsTouchingRightWall() => CollisionSensor.IsTouchingRightWall(playerCollider.bounds.center, playerCollider.bounds.size);
Ejemplo n.º 17
0
 public void Connect(string strName, out CollisionSensor item)
 {
     ExAddProperty(this.m_pSelf, strName, 4, 0x32c8);
     item = null;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Whether or not a collision can be considered a valid "ground" collision.
 /// </summary>
 /// <param name="collider">The collider of the object that might be hitting
 /// the player.</param>
 /// <param name="hitNormal">The normal for the collision.</param>
 /// <param name="checkNormal">The normal expected.</param>
 /// <returns>True if this is a valid "ground" hit. False otherwise.</returns>
 public bool IsHitBy(Collider2D collider, Vector2?hitNormal = null, Vector2?checkNormal = null) => CollisionSensor.IsHit(collider, hitNormal, checkNormal);
Ejemplo n.º 19
0
 /// <summary>
 /// Whether or not a box will fit in a position one space to the right of where it
 /// currently is.
 /// </summary>
 /// <param name="direction">The direction to check</param>
 /// <returns>Returns true if the box would fit in the space directly to its right.</returns>
 public bool FitsInDirection(Vector2 direction, out Collider2D[] hits) => CollisionSensor.FitsInDirection(playerCollider.bounds.center, playerCollider.bounds.size, direction, out hits);
Ejemplo n.º 20
0
 /// <summary>
 /// Whether or not the object is touching the ceiling.
 /// </summary>
 public bool IsTouchingCeiling() => CollisionSensor.IsTouchingCeiling(playerCollider.bounds.center, playerCollider.bounds.size);