Example #1
0
    //private HingeJoint hinge;

    // Start is called before the first frame update
    void Start()
    {
        jumpTrigger  = GetComponentInChildren <JumpTrigger>();
        rb           = GetComponent <Rigidbody>();
        initialScale = transform.localScale;
        grappleHit   = Instantiate(grappleHitPrefab, Vector3.zero, Quaternion.identity);
        //hinge = grappleHit.GetComponent<HingeJoint>();
    }
Example #2
0
 void Start()
 {
     gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();
     _rb            = GetComponent <Rigidbody2D>();
     boxCollider    = GetComponent <CapsuleCollider2D>();
     spriteRenderer = sprite.GetComponent <SpriteRenderer>();
     animator       = sprite.GetComponent <Animator>();
     jumpTrigger    = jumpDetect.GetComponent <JumpTrigger>();
     Freeze();
 }
 protected virtual void OnTriggerExit2D(Collider2D collider)
 {
     if (collider.isTrigger)
     {
         Trigger trigger = collider.GetComponent <Trigger> ();
         if (trigger == null)
         {
             return;
         }
         else if (TriggerAffects(trigger))
         {
             if (trigger.type == Trigger.JUMP_TRIGGER)
             {
                 activeJumpTrigger = null;
             }
         }
     }
 }
 protected virtual void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.isTrigger)
     {
         Trigger trigger = collider.GetComponent <Trigger> ();
         if (trigger == null)
         {
             return;
         }
         else if (this is Player && trigger.affectPlayer || this is Enemy && trigger.affectEnemy)
         {
             if (trigger.type == Trigger.JUMP_TRIGGER)
             {
                 activeJumpTrigger = (JumpTrigger)trigger;
             }
         }
     }
 }
Example #5
0
        private void TryLanding()
        {
            PrevGrounded = Grounded;

            if (JumpTrigger.Update(Owner.Position) && !JumpWait)
            {
                Grounded   = true;
                _jumpsLeft = MaxJumps;
            }
            else
            {
                Grounded = false;
            }

            if (!Grounded)
            {
                FallVelocity = Velocity.Y;
            }
            else
            {
                if (!PrevGrounded)
                {
                    if (FallVelocity < -0.5f)
                    {
                        //Emit Particles
                        foreach (Component c in _owner.Components)
                        {
                            if (c is Emitter && c.Tags.Contains("Landing"))
                            {
                                Emitter e = c as Emitter;
                                e.Emit();
                            }
                        }
                        float trauma = -((FallVelocity + 0.5f) / 40.0f);
                        if (trauma > 0.6f)
                        {
                            trauma = 0.6f;
                        }
                        ScreenShakeManager.Instance.AddTrauma(trauma);
                        FallVelocity = 0;
                    }
                }
            }
        }
Example #6
0
        public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
        {
            NativeArray <PhysicsVelocity> chunkVelocities    = chunk.GetNativeArray(Velocity);
            NativeArray <JumpCount>       chunkJumpCount     = chunk.GetNativeArray(JumpCount);
            NativeArray <JumpForce>       chunkJumpForces    = chunk.GetNativeArray(JumpForce);
            NativeArray <MaxJumpCount>    chunkMaxJumpCounts = chunk.GetNativeArray(MaxJumpCount);
            NativeArray <JumpTrigger>     chunkJumpTrigger   = chunk.GetNativeArray(JumpTrigger);

            for (int i = 0; i < chunk.Count; i++)
            {
                if (!chunkJumpTrigger[i].Value)
                {
                    return;
                }

                chunkJumpTrigger[i] = new JumpTrigger()
                {
                    Value = false
                };

                chunkJumpCount[i] = new JumpCount()
                {
                    Value = chunkJumpCount[i].Value + 1
                };

                if (chunkJumpCount[i].Value > chunkMaxJumpCounts[i].Value)
                {
                    return;
                }

                chunkVelocities[i] = new PhysicsVelocity
                {
                    Angular = chunkVelocities[i].Angular,
                    Linear  = math.select(chunkVelocities[i].Linear + new float3(0, chunkJumpForces[i].Value, 0),
                                          new float3(chunkVelocities[i].Linear.x, chunkJumpForces[i].Value, chunkVelocities[i].Linear.z),
                                          chunkJumpForces[i].IsAbsolute)
                };
            }
        }
Example #7
0
 // Start is called before the first frame update
 void Start()
 {
     worm        = GameObject.FindGameObjectWithTag("Player").transform;
     jumpTrigger = worm.gameObject.GetComponentInChildren <JumpTrigger>();
 }
Example #8
0
 public override void DebugDraw(SpriteBatch spriteBatch)
 {
     JumpTrigger.DebugDraw(spriteBatch);
 }
Example #9
0
 public override void Load(ContentManager content)
 {
     JumpTrigger.Load(content);
 }
Example #10
0
 private void FakeJump()
 {
     JumpTrigger.Activate();
 }