Пример #1
0
 public bool IsOnAmmo(BoxCollider other)
 {
     if (collider.IsOverlapping2(other))
     {
         return(true);
     }
     return(false);
 }
Пример #2
0
        // This is used to move the tank
        public void Move(float deltaTime)
        {
            if (tankObject != null)
            {
                if (collider.IsOverlapping2(mousePoint))
                {
                    stopTank = true;
                }
                else
                {
                    stopTank = false;
                }
                // Boolean used to stop the tank
                if (!stopTank && !collider.IsOverlapping2(mousePoint))
                {
                    float   angle = 0;
                    float   diff  = CUtils.Distance(GetMousePosition(), tankObject.position, out angle);
                    Vector2 face  = tankObject.forward * tankSpeed * 30 * deltaTime;
                    tankObject.Translate(face);
                    tankObject.SetRotate(angle);
                    // Just checking to see if the tank is out of the screen and if it is It will come back on the a different part of the screen

                    if (!CUtils.IsObjectInScreen(tankObject))
                    {
                        if (position.y < 0 - tankScreenOffset)
                        {
                            tankObject.SetPosition(position.x, GetScreenHeight());
                        }
                        if (position.y > GetScreenHeight())
                        {
                            tankObject.SetPosition(position.x, 0 - tankScreenOffset);
                        }
                        if (position.x < 0 - tankScreenOffset)
                        {
                            tankObject.SetPosition(GetScreenWidth(), position.y);
                        }
                        if (position.x > GetScreenWidth())
                        {
                            tankObject.SetPosition(0 - tankScreenOffset, position.y);
                        }
                    }
                }
            }
        }