Ejemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (RayCasts.IsGroundTileBelowBy(transform, 0.025f))
     {
         Destroy(gameObject);
     }
     cLifetime += Time.deltaTime;
 }
Ejemplo n.º 2
0
 public virtual void Update()
 {
     if (IsMidJump && IsDecending())
     {
         IsMidJump = false;
     }
     if (RayCasts.IsGroundTileBelowBy(transform, GroundCheckDistance) && !IsMidJump)
     {
         if (JumpDirection.x >= 0)
         {
             GroundClaimsService.GetInstance().LeftTeamClaimUpdate(transform.localPosition.x);
         }
         else
         {
             GroundClaimsService.GetInstance().RightTeamClaimUpdate(transform.localPosition.x);
         }
         if (AllowMovement)
         {
             Jump();
         }
     }
     //put the breaks on if moving too fast
     if (Mathf.Abs(Body.velocity.x) > JumpForce.x)
     {
         if (JumpDirection.normalized.x > 0)
         {
             if (Body.velocity.x > 0)
             {
                 //slow down
                 Body.AddForce(-JumpDirection.normalized * JumpForce.x);
             }
             else
             {
                 //speed up
                 Body.AddForce(JumpDirection.normalized * JumpForce.x);
             }
         }
         else
         {
             if (Body.velocity.x < 0)
             {
                 //slow down
                 Body.AddForce(-JumpDirection.normalized * JumpForce.x);
             }
             else
             {
                 //speed up
                 Body.AddForce(JumpDirection.normalized * JumpForce.x);
             }
         }
     }
 }
Ejemplo n.º 3
0
 public void Update()
 {
     if (!StuckInGround)
     {
         Vector3 normVelocity = Body.velocity.normalized;
         //Calculate renderable rotation
         Renderable.right = transform.position - (transform.position + normVelocity);
         if (RayCasts.IsGroundTileBelowBy(transform, 0.05f))
         {
             StuckInGround      = true;
             transform.position = transform.position + (Vector3)Body.velocity * Time.deltaTime;
             StartCoroutine(StayStillThenDestroy());
         }
     }
 }
Ejemplo n.º 4
0
 void Update()
 {
     if (RayCasts.IsGroundTileBelowBy(transform, 0.1f))
     {
         int roll = Dice.Roll(20, 25);
         for (int x = 0; x < roll; x++)
         {
             float            xForce   = Dice.Roll(-1f, 1f);
             float            yForce   = Dice.Roll(0.5f, 1f);
             FireballShrapnel shrapnel = Instantiate(FireballShrapnelPrefab);
             shrapnel.gameObject.layer   = gameObject.layer;
             shrapnel.transform.position = transform.position;
             shrapnel.Body.AddForce(new Vector2(xForce, yForce), ForceMode2D.Impulse);
             shrapnel.transform.SetParent(transform.parent);
         }
         Destroy(gameObject);
     }
 }