Ejemplo n.º 1
0
        /// <summary>
        /// Adds base to the game.
        /// </summary>
        /// <param name="newBase">The new base</param>
        public void AddBase(Base newBase)
        {
            bases.Add(newBase.EventId, newBase);
            bases[newBase.EventId].RenderID = ServiceManager.Scene.Add(bases[newBase.EventId], 0);

            if (bases.Count >= 6)
            {
                // Special case handler: if CTB mode, make player face next tower.
                Client.src.states.gamestate.State currentState = ServiceManager.StateManager.CurrentState;
                if (currentState is Client.src.states.gamestate.GamePlayState)
                {
                    PlayerTank localPlayer = ((Client.src.states.gamestate.GamePlayState)currentState).LocalPlayer;
                    const int BLUE_FRONT = 10;
                    const int RED_FRONT = 11;
                    Base blueBase = GetBase(BLUE_FRONT);
                    Base redBase = GetBase(RED_FRONT);

                    if (localPlayer.Team == GameSession.Alliance.RED)
                    {
                        localPlayer.Angle = (float)Math.Atan2(
                            blueBase.Position.Y - redBase.Position.Y,
                            blueBase.Position.X - redBase.Position.X);
                    }
                    else
                    {
                        localPlayer.Angle = (float)Math.Atan2(
                            redBase.Position.Y - blueBase.Position.Y,
                            redBase.Position.X - blueBase.Position.X);
                    }
                    Client.src.states.gamestate.GamePlayState game =
                        (Client.src.states.gamestate.GamePlayState)currentState;
                    game.Scene.LockCameras();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a base to the game.
        /// </summary>
        /// <param name="color">Team color of the base.</param>
        /// <param name="eventId">Event ID of the base.</param>
        /// <param name="position">Position of the base.</param>
        public void AddBase(GameSession.Alliance color, int eventId, Vector3 position)
        {
            Model baseModel = ServiceManager.Resources.GetModel("events\\base");
            Base newBase = new Base(color, position, eventId, baseModel);

            AddBase(newBase);
        }