Ejemplo n.º 1
0
        public VisualizerCommandSet Initialization()
        {
            var set = new VisualizerCommandSet();

            if (Box)
            {
                AddBox(set);
            }

            foreach (var triangle in surfaces)
            {
                var tri = new Triangle3D(
                    UtilityFunctions.ConvertVector(triangle.Points[0]),
                    UtilityFunctions.ConvertVector(triangle.Points[1]),
                    UtilityFunctions.ConvertVector(triangle.Points[2]), true);
                var obj = new ObjectPrototype(tri, UtilityFunctions.ConvertColor(triangle.Color), triangle.IsTransparent);
                set.AddCommand(new AddObject(obj, counter++));
            }

            // Add all the projectiles
            foreach (var projectile in projectiles)
            {
                // Start it off in the right place
                var obj = new ObjectPrototype(projectile.Shape, new BasicMaterial(projectile.Color),
                                              projectile.Position, new Vector3D(projectile.Size, projectile.Size, projectile.Size));

                set.AddCommand(new AddObject(obj, counter));
                projectileMap.Add(counter, projectile);
                ++counter;
            }

            // Add all the connectors
            foreach (var connector in connectorMap)
            {
                // Update them first so they are in the right position
                connector.Value.Update();
                var obj = new ObjectPrototype(new VisualizerControl.Shapes.CaplessCylinder3D(),
                                              new BasicMaterial(connector.Value.Color));
                set.AddCommand(new AddObject(obj, connector.Key));
                set.AddCommand(connector.Value.GetTransformCommand(connector.Key));
            }

            return(set);
        }
Ejemplo n.º 2
0
    /// <summary>
    /// Handles input during the discovery phase of the game.
    /// </summary>
    /// <remarks>
    /// Escape opens the game menu. Clicking the mouse will
    /// attack a location.
    /// </remarks>
    public static void HandleDiscoveryInput()
    {
        if (SwinGame.KeyTyped(KeyCode.vk_ESCAPE))
        {
            GameController.AddNewState(GameState.ViewingGameMenu);
        }

        if (SwinGame.MouseClicked(MouseButton.LeftButton))
        {
            DoAttack();
        }

        //added by jesse -- coordinate for home button to back homepage
        if (SwinGame.MouseClicked(MouseButton.LeftButton) & UtilityFunctions.IsMouseInRectangle
                (685, 70, 51, 46))
        {
            GameController.AddNewState(GameState.ViewingGameMenu);
        }
    }
Ejemplo n.º 3
0
        public void Givenlongegers_GenerateSubsets()
        {
            //Arrange
            var elements = new List <long> {
                1, 2, 3
            };
            var expected = new List <List <long> >
            {
                new List <long> {
                },
                new List <long> {
                    1
                },
                new List <long> {
                    2
                },
                new List <long> {
                    1, 2
                },
                new List <long> {
                    3
                },
                new List <long> {
                    1, 3
                },
                new List <long> {
                    2, 3
                },
                new List <long> {
                    1, 2, 3
                },
            };

            //Act
            var actual = UtilityFunctions.GenerateSubsets(elements);

            //Assert
            Assert.Equal(expected.Count, actual.Count);
            for (int i = 0; i < actual.Count; i++)
            {
                Assert.True(Enumerable.SequenceEqual(expected[i], actual[i]));
            }
        }
Ejemplo n.º 4
0
    /// <summary>
    /// Handles user input for the Deployment phase of the game.
    /// </summary>
    /// <remarks>
    /// Involves selecting the ships, deloying ships, changing the direction
    /// of the ships to add, randomising deployment, end then ending
    /// deployment
    /// </remarks>
    public static void HandleDeploymentInput()
    {
        if (SwinGame.KeyTyped(KeyCode.vk_ESCAPE))
        {
            GameController.AddNewState(GameState.ViewingGameMenu);
        }

        if (SwinGame.KeyTyped(KeyCode.vk_UP) | SwinGame.KeyTyped(KeyCode.vk_DOWN))
        {
            _currentDirection = Direction.UpDown;
        }
        if (SwinGame.KeyTyped(KeyCode.vk_LEFT) | SwinGame.KeyTyped(KeyCode.vk_RIGHT))
        {
            _currentDirection = Direction.LeftRight;
        }

        if (SwinGame.KeyTyped(KeyCode.vk_r))
        {
            GameController.HumanPlayer.RandomizeDeployment();
        }

        if (SwinGame.MouseClicked(MouseButton.LeftButton))
        {
            ShipName selected = GetShipMouseIsOver();
            if (selected != ShipName.None)
            {
                _selectedShip = selected;
            }
            else
            {
                DoDeployClick();
            }

            if (GameController.HumanPlayer.ReadyToDeploy & UtilityFunctions.IsMouseInRectangle(PLAY_BUTTON_LEFT, TOP_BUTTONS_TOP, PLAY_BUTTON_WIDTH, TOP_BUTTONS_HEIGHT))
            {
                GameController.EndDeployment();
            }
            else
            {
                AdjustShipDirectionFromButtons(UtilityFunctions.IsMouseInRectangle);
            }
        }
    }
Ejemplo n.º 5
0
 // Update is called once per frame
 void Update()
 {
     if (WayPointTarget == null)
     {
         UtilityFunctions.DebugMessage("Finding waypoint through update");
         WayPointTarget = PathingScript.FindClosestWayPointToSelfAndTarget(transform, WayPointTarget, Target);
         if (WayPointTarget == null)
         {
             WayPointTarget = Target;
         }
     }
     if (!Afflictions.Any(x => x.AfflictionType == AfflictionTypes.Stun))
     {
         if (IsFighting && FightingTarget != null)
         {
             if ((UtilityFunctions.UseUnitZPosition(transform, transform.position) - UtilityFunctions.UseUnitZPosition(transform, FightingTarget.position)).sqrMagnitude > DistanceBetweenMeleeFighters)
             {
                 UtilityFunctions.DebugMessage("Moving towards melee target.");
                 IsMovingTowardFighter = true;
                 float unitSpeedAdjustment = GetUnitSpeedAdjustment();
                 float newUnitSpeed        = unitSpeedAdjustment * UnitSpeed;
                 transform.position += (UseUnitZPosition(FightingTarget.position) - transform.position).normalized * Time.deltaTime * newUnitSpeed;
             }
             else
             {
                 IsMovingTowardFighter = false;
                 Attack();
             }
         }
         else if (IsFighting)
         {
             IsMovingTowardFighter = false;
             IsFighting            = false;
         }
         else
         {
             float unitSpeedAdjustment = GetUnitSpeedAdjustment();
             float newUnitSpeed        = unitSpeedAdjustment * UnitSpeed;
             transform.position += (UseUnitZPosition(WayPointTarget.transform.position) - transform.position).normalized * Time.deltaTime * newUnitSpeed;
         }
     }
     Afflictions.RemoveAll(x => x.EndTime <= Time.time);
 }
Ejemplo n.º 6
0
    public static List <List <Vector2> > BuildAIPaths()
    {
        // get spawn points
        GameObject[] spawns = GameObject.FindGameObjectsWithTag("Spawn");

        // get base
        Transform baseBuilding = GameObject.FindGameObjectWithTag("Base").transform;

        var paths = new List <List <Vector2> >();

        // loop and build each one
        foreach (GameObject spawn in spawns)
        {
            List <Vector2> path = new List <Vector2>();

            Transform currentPosition = new GameObject().transform;
            currentPosition.position = spawn.transform.position;

            Transform previousWayPoint = null;

            currentPosition = FindClosestWayPointToSelfAndTarget(currentPosition, previousWayPoint, baseBuilding);

            // add nodes to path
            path.Add(spawn.transform.position);
            path.Add(currentPosition.transform.position);

            int loopBreak = 0;
            // loop till base reached, always take closest, exclude previous node
            while (!baseBuilding.GetComponent <Collider2D>().bounds.Contains(UtilityFunctions.UseUnitZPosition(baseBuilding, currentPosition.transform.position)) && loopBreak < 50)
            {
                loopBreak++;
                previousWayPoint = currentPosition;
                currentPosition  = FindClosestWayPointToSelfAndTarget(currentPosition, previousWayPoint, baseBuilding);

                //add vector to path
                path.Add(currentPosition.transform.position);
            }

            paths.Add(path);
        }

        return(paths);
    }
Ejemplo n.º 7
0
    /// <summary>
    /// Draws the current state of the game to the screen.
    /// </summary>
    /// <remarks>
    /// What is drawn depends upon the state of the game.
    /// </remarks>
    public static void DrawScreen()
    {
        UtilityFunctions.DrawBackground();

        switch (CurrentState)
        {
        case GameState.ViewingMainMenu:
            MenuController.DrawMainMenu();
            break;

        case GameState.ViewingGameMenu:
            MenuController.DrawGameMenu();
            break;

        case GameState.AlteringSettings:
            MenuController.DrawSettings();
            break;

        case GameState.AlteringAudio:
            MenuController.DrawAudio();
            break;

        case GameState.Deploying:
            DeploymentController.DrawDeployment();
            break;

        case GameState.Discovering:
            DiscoveryController.DrawDiscovery();
            break;

        case GameState.EndingGame:
            EndingGameController.DrawEndOfGame();
            break;

        case GameState.ViewingHighScores:
            HighScoreController.DrawHighScores();
            break;
        }

        UtilityFunctions.DrawAnimations();

        SwinGame.RefreshScreen();
    }
Ejemplo n.º 8
0
    /// <summary>
    /// Draws the deployment screen showing the field and the ships
    /// that the player can deploy.
    /// </summary>
    public static void DrawDeployment()
    {
        UtilityFunctions.DrawField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer, true);

        //Draw the Left/Right and Up/Down buttons
        if (_currentDirection == Direction.LeftRight)
        {
            SwinGame.DrawBitmap(GameResources.GameImage("LeftRightButton"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP);
            //SwinGame.DrawText("U/D", Color.Gray, GameFont("Menu"), UP_DOWN_BUTTON_LEFT, TOP_BUTTONS_TOP)
            //SwinGame.DrawText("L/R", Color.White, GameFont("Menu"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP)
        }
        else
        {
            SwinGame.DrawBitmap(GameResources.GameImage("UpDownButton"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP);
            //SwinGame.DrawText("U/D", Color.White, GameFont("Menu"), UP_DOWN_BUTTON_LEFT, TOP_BUTTONS_TOP)
            //SwinGame.DrawText("L/R", Color.Gray, GameFont("Menu"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP)
        }


        //DrawShips
        foreach (ShipName sn in Enum.GetValues(typeof(ShipName)))
        {
            int i = 0;
            i = ((int)sn) - 1;
            if (i >= 0)
            {
                if (sn == _selectedShip)
                {
                    SwinGame.DrawBitmap(GameResources.GameImage("SelectedShip"), SHIPS_LEFT, SHIPS_TOP + i * SHIPS_HEIGHT);
                    //    SwinGame.FillRectangle(Color.LightBlue, SHIPS_LEFT, SHIPS_TOP + i * SHIPS_HEIGHT, SHIPS_WIDTH, SHIPS_HEIGHT)
                    //Else
                    //    SwinGame.FillRectangle(Color.Gray, SHIPS_LEFT, SHIPS_TOP + i * SHIPS_HEIGHT, SHIPS_WIDTH, SHIPS_HEIGHT)
                }

                //SwinGame.DrawRectangle(Color.Black, SHIPS_LEFT, SHIPS_TOP + i * SHIPS_HEIGHT, SHIPS_WIDTH, SHIPS_HEIGHT)
                //SwinGame.DrawText(sn.ToString(), Color.Black, GameFont("Courier"), SHIPS_LEFT + TEXT_OFFSET, SHIPS_TOP + i * SHIPS_HEIGHT)
            }
        }
        // '' <summary>
        // '' Gets the ship that the mouse is currently over in the selection panel.
        // '' </summary>
        // '' <returns>The ship selected or none</returns>
    }
Ejemplo n.º 9
0
    public static void HandleDiscoveryInput()
    {
        if (SwinGame.KeyTyped(KeyCode.EscapeKey))
        {
            GameController.AddNewState(GameState.ViewingGameMenu);
        }

        if (SwinGame.MouseClicked(MouseButton.LeftButton))
        {
            if (UtilityFunctions.IsMouseInRectangle(BACK_BUTTON_LEFT, TOP_BUTTONS_TOP, BACK_BUTTON_WIDTH, TOP_BUTTONS_HEIGHT))
            {
                GameController.AddNewState(GameState.ViewingGameMenu);
            }
            else
            {
                DoAttack();
            }
        }
    }
Ejemplo n.º 10
0
    /// <summary>
    /// Draw the end of the game screen, shows the win/lose state
    /// </summary>
    public static void DrawEndOfGame()
    {
        UtilityFunctions.DrawField(GameController.ComputerPlayer.PlayerGrid, GameController.ComputerPlayer, true);
        UtilityFunctions.DrawSmallField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer);
        Rectangle toDraw = new Rectangle();

        toDraw.X      = 0;
        toDraw.Y      = 250;
        toDraw.Width  = SwinGame.ScreenWidth();
        toDraw.Height = SwinGame.ScreenHeight();
        if (GameController.HumanPlayer.IsDestroyed)
        {
            SwinGame.DrawText("YOU LOSE!", Color.White, Color.Transparent, GameResources.GameFont("ArialLarge"), FontAlignment.AlignCenter, toDraw);
        }
        else
        {
            SwinGame.DrawText("-- WINNER --", Color.White, Color.Transparent, GameResources.GameFont("ArialLarge"), FontAlignment.AlignCenter, toDraw);
        }
    }
Ejemplo n.º 11
0
    void FixedUpdate()
    {
        if (LeftRight.axisValue != 0 || UpDown.axisValue != 0)
        {
            float yRot = UtilityFunctions.TrigToAngleDEG(UpDown.axisValue, LeftRight.axisValue);

            targetRot = Quaternion.Euler(0f, yRot, 0f);
        }

        if (smooth)
        {
            transform.rotation = Quaternion.Slerp(transform.rotation, targetRot,
                                                  smoothTime * Time.deltaTime);
        }
        else
        {
            transform.rotation = targetRot;
        }
    }
Ejemplo n.º 12
0
    /// <summary>
    /// Read the user's name for their highsSwinGame.
    /// </summary>
    /// <param name="value">the player's sSwinGame.</param>
    /// <remarks>
    /// This verifies if the score is a highsSwinGame.
    /// </remarks>
    public static void ReadHighScore(int value)
    {
        const int ENTRY_TOP = 500;

        if (_Scores.Count == 0)
        {
            LoadScores();
        }

        // is it a high score
        if (value > _Scores[_Scores.Count - 1].Value)
        {
            Score s = new Score();
            s.Value = value;
            GameController.AddNewState(GameState.ViewingHighScores);

            int x = 0;
            x = SCORES_LEFT + SwinGame.TextWidth(GameResources.GameFont("Courier"), "Name: ");
            SwinGame.StartReadingText(Color.White, NAME_WIDTH, GameResources.GameFont("Courier"), x, ENTRY_TOP);

            // Read the text from the user
            while (SwinGame.ReadingText())
            {
                SwinGame.ProcessEvents();
                UtilityFunctions.DrawBackground();
                DrawHighScores();
                SwinGame.DrawText("Name: ", Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, ENTRY_TOP);
                SwinGame.RefreshScreen();
            }

            s.Name = SwinGame.TextReadAsASCII();
            if (s.Name.Length < 3)
            {
                s.Name = s.Name + new string(Convert.ToChar(' '), 3 - s.Name.Length);
            }

            _Scores.RemoveAt(_Scores.Count - 1);
            _Scores.Add(s);
            _Scores.Sort();

            GameController.EndCurrentState();
        }
    }
Ejemplo n.º 13
0
        public static void GeneratePermutationsTest()
        {
            //Arrange
            var elements = new List <int> {
                1, 2, 3, 4
            };
            var expected = new List <List <int> > {
                new List <int> {
                    2, 1
                }, new List <int> {
                    3, 1
                }, new List <int> {
                    4, 1
                },
                new List <int> {
                    1, 2
                }, new List <int> {
                    3, 2
                }, new List <int> {
                    4, 2
                },
                new List <int> {
                    1, 3
                }, new List <int> {
                    2, 3
                }, new List <int> {
                    4, 3
                },
                new List <int> {
                    1, 4
                }, new List <int> {
                    2, 4
                }, new List <int> {
                    3, 4
                },
            };

            //Act
            var actual = UtilityFunctions.GeneratePermutations(elements, 2);

            //Assert
            Assert.Equal(expected, actual);
        }
        public async Task <JsonResult> UpdateVacation([FromBody] List <VacationDataViewModel> vacations)
        {
            var loggedUser = UtilityFunctions.GetLoggedUser(User.Claims);

            var update = await _vacationService.UpdateVacationAsync(vacations, loggedUser);

            if (update.Success)
            {
                var result = Json(update);
                result.StatusCode = ApplicationConstants.HTTP_RESPONSE_OK;
                return(result);
            }
            else
            {
                var result = Json(update);
                result.StatusCode = ApplicationConstants.HTTP_RESPONSE_UNPROCESSABLE_ENTITY;
                return(result);
            }
        }
Ejemplo n.º 15
0
 protected void DdlAddMonts_SelectedIndexChanged(object Sender, EventArgs e)
 {
     try
     {
         if (TxtFromYear.Text.Length > 0)// && TxtToYear.Text.Length > 0)
         {
             DateTime selectedFromMonth = UtilityFunctions.MapValue <DateTime>(TxtFromYear.Text, typeof(DateTime));
             //if (DdlAddMonths.SelectedIndex > 0)
             {
                 selectedFromMonth = selectedFromMonth.AddMonths(UtilityFunctions.MapValue <int>(DdlAddMonths.SelectedValue, typeof(int)));
                 TxtToYear.Text    = selectedFromMonth.ToString("MM/dd/yyyy");
             }
             ClassesGetByCourseID();
         }
     }
     catch (Exception ex)
     {
     }
 }
        public async Task <JsonResult> DeleteUserData([FromBody] int id)
        {
            var loggedUser = UtilityFunctions.GetLoggedUser(User.Claims);

            var update = await _userService.DeleteUserDataAsync(id, loggedUser);

            if (update.Success)
            {
                var result = Json(update);
                result.StatusCode = ApplicationConstants.HTTP_RESPONSE_OK;
                return(result);
            }
            else
            {
                var result = Json(update);
                result.StatusCode = ApplicationConstants.HTTP_RESPONSE_UNPROCESSABLE_ENTITY;
                return(result);
            }
        }
Ejemplo n.º 17
0
        private static void AddRecipe()
        {
            var recipe    = ScriptableObject.CreateInstance <Recipe>();
            var recipeBR  = ScriptableObject.CreateInstance <Recipe>();
            var recipeBM  = ScriptableObject.CreateInstance <Recipe>();
            var recipeSil = ScriptableObject.CreateInstance <Recipe>();

            recipe.m_item    = AssetHelper.BattleaxeBlackmetalPrefab.GetComponent <ItemDrop>();
            recipeBR.m_item  = AssetHelper.BattleaxeBronzePrefab.GetComponent <ItemDrop>();
            recipeBM.m_item  = AssetHelper.GreateaxeBlackmetalPrefab.GetComponent <ItemDrop>();
            recipeSil.m_item = AssetHelper.BattleaxeSilverPrefab.GetComponent <ItemDrop>();

            UtilityFunctions.GetRecipe(ref recipe, balance["AxehammerBlackmetal"]);

            UtilityFunctions.GetRecipe(ref recipeBM, balance["BattleaxeBlackmetal"]);

            UtilityFunctions.GetRecipe(ref recipeBR, balance["BattleaxeBronze"]);

            UtilityFunctions.GetRecipe(ref recipeSil, balance["BattleaxeSilver"]);

            customRecipe       = new CustomRecipe(recipe, true, true);
            customRecipeBronze = new CustomRecipe(recipeBR, true, true);
            customRecipeBM     = new CustomRecipe(recipeBM, true, true);
            customRecipeSil    = new CustomRecipe(recipeSil, true, true);

            if ((bool)balance["BattleaxeBronze"]["enabled"])
            {
                ItemManager.Instance.AddRecipe(customRecipe);
            }
            if ((bool)balance["BattleaxeBlackmetal"]["enabled"])
            {
                ItemManager.Instance.AddRecipe(customRecipeBronze);
            }
            if ((bool)balance["BattleaxeSilver"]["enabled"])
            {
                ItemManager.Instance.AddRecipe(customRecipeBM);
            }
            if ((bool)balance["AxehammerBlackmetal"]["enabled"])
            {
                ItemManager.Instance.AddRecipe(customRecipeSil);
            }
        }
Ejemplo n.º 18
0
    // Update is called once per frame
    void Update()
    {
        if (enemyController.freezeEnemy)
        {
            // add anything here to happen while frozen i.e. time compensations
            // path start time for bezier curve gets annihilated when frozen - compensate
            pathTimeStart += Time.deltaTime;
            return;
        }

        // play animation
        animator.Play("KillerBomb_Flying");

        // calculate next travel path when previous is completed
        if (!isFollowingPath)
        {
            // distance/length to the next end point, get start point from rigidbody position,
            // end point is calculated by adding the distance to start point
            // middle point is calculated and the height is applied to form the curve
            // start time is needed to determine the point in the curve we want
            // i.e. this is just like LERPing
            float distance = (isFacingRight) ? bezierDistance : -bezierDistance;
            pathStartPoint  = rb2d.transform.position;
            pathEndPoint    = new Vector3(pathStartPoint.x + distance, pathStartPoint.y, pathStartPoint.z);
            pathMidPoint    = pathStartPoint + (((pathEndPoint - pathStartPoint) / 2) + bezierHeight);
            pathTimeStart   = Time.time;
            isFollowingPath = true;
        }
        else
        {
            // percentage is the point in the curve we want and update our rigidbody position
            float percentage = (Time.time - pathTimeStart) / bezierTime;
            rb2d.transform.position = UtilityFunctions.CalculateQuadraticBezierPoint(pathStartPoint, pathMidPoint, pathEndPoint, percentage);
            // end of the curve has been reach
            if (percentage >= 1f)
            {
                // invert the height - this is what creates the flying wave effect
                bezierHeight   *= -1;
                isFollowingPath = false;
            }
        }
    }
Ejemplo n.º 19
0
        public BaseEntity(MyObjectBuilder_EntityBase baseEntity, Object backingObject)
            : base(baseEntity, backingObject)
        {
            if (baseEntity != null)
            {
                m_entityId = baseEntity.EntityId;
                if (baseEntity.PositionAndOrientation != null)
                {
                    m_positionOrientation = baseEntity.PositionAndOrientation.GetValueOrDefault( );
                }
                else
                {
                    m_positionOrientation          = new MyPositionAndOrientation( );
                    m_positionOrientation.Position = UtilityFunctions.GenerateRandomBorderPosition(new Vector3(-500000, -500000, -500000), new Vector3(500000, 500000, 500000));
                    m_positionOrientation.Forward  = new Vector3(0, 0, 1);
                    m_positionOrientation.Up       = new Vector3(0, 1, 0);
                }
            }
            else
            {
                m_entityId                     = 0;
                m_positionOrientation          = new MyPositionAndOrientation( );
                m_positionOrientation.Position = UtilityFunctions.GenerateRandomBorderPosition(new Vector3(-500000, -500000, -500000), new Vector3(500000, 500000, 500000));
                m_positionOrientation.Forward  = new Vector3(0, 0, 1);
                m_positionOrientation.Up       = new Vector3(0, 1, 0);
            }

            m_networkManager = new BaseEntityNetworkManager(this, GetEntityNetworkManager(BackingObject));

            m_linearVelocity    = new Vector3(0, 0, 0);
            m_angularVelocity   = new Vector3(0, 0, 0);
            m_maxLinearVelocity = (float)104.7;

            if (EntityId != 0)
            {
                GameEntityManager.AddEntity(EntityId, this);
            }

            Action action = InternalRegisterEntityMovedEvent;

            SandboxGameAssemblyWrapper.Instance.EnqueueMainGameAction(action);
        }
Ejemplo n.º 20
0
    /// <summary>
    /// Handles the user SwinGame.
    /// </summary>
    /// <remarks>
    /// Reads key and mouse input and converts these into
    /// actions for the game to perform. The actions
    /// performed depend upon the state of the game.
    /// </remarks>
    public static void HandleUserInput()
    {
        // Read incoming input events
        SwinGame.ProcessEvents();

        switch (CurrentState)
        {
        case GameState.ViewingMainMenu:
            MenuController.HandleMainMenuInput();
            break;

        case GameState.ViewingGameMenu:
            MenuController.HandleGameMenuInput();
            break;

        case GameState.AlteringSettings:
            MenuController.HandleSetupMenuInput();
            break;

        case GameState.AlteringAudio:
            MenuController.HandleAudioMenuInput();
            break;

        case GameState.Deploying:
            DeploymentController.HandleDeploymentInput();
            break;

        case GameState.Discovering:
            DiscoveryController.HandleDiscoveryInput(countdown);
            break;

        case GameState.EndingGame:
            EndingGameController.HandleEndOfGameInput();
            break;

        case GameState.ViewingHighScores:
            HighScoreController.HandleHighScoreInput();
            break;
        }

        UtilityFunctions.UpdateAnimations();
    }
Ejemplo n.º 21
0
    /// <summary>
    /// Draws the game during the attack phase.
    /// </summary>s
    public static void DrawDiscovery()
    {
        const int SCORES_LEFT = 172;
        const int SHOTS_TOP   = 157;
        const int HITS_TOP    = 206;
        const int SPLASH_TOP  = 256;

        //Added By Jesse
        const int SCORE_TOP = 306;

        if (((SwinGame.KeyDown(KeyCode.vk_LSHIFT) | SwinGame.KeyDown(KeyCode.vk_RSHIFT)) & SwinGame.KeyDown(KeyCode.vk_c)))
        {
            UtilityFunctions.DrawField(GameController.HumanPlayer.EnemyGrid, GameController.ComputerPlayer, true);
        }
        else
        {
            UtilityFunctions.DrawField(GameController.HumanPlayer.EnemyGrid, GameController.ComputerPlayer, false);
        }

        UtilityFunctions.DrawSmallField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer);
        UtilityFunctions.DrawMessage();

        //Added by Voon.
        //Draw Destroyed Ships.
        UtilityFunctions.DrawDestroyField(GameController.ComputerPlayer.PlayerGrid, GameController.ComputerPlayer, true);

        SwinGame.DrawText(GameController.HumanPlayer.Shots.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, SHOTS_TOP);
        SwinGame.DrawText(GameController.HumanPlayer.Hits.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, HITS_TOP);
        SwinGame.DrawText(GameController.HumanPlayer.Missed.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, SPLASH_TOP);

        //Added by Jesse
        SwinGame.DrawText(GameController.HumanPlayer.Score.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, SCORE_TOP);


        //Added by Voon.
        //Draw the number of ships left that need to destroy.
        SwinGame.DrawText("Number of Ships left: ", Color.White, GameResources.GameFont("Menu"), 350, 90);
        SwinGame.DrawText((5 - GameController.ComputerPlayer.PlayerGrid.ShipsKilled).ToString(), Color.Yellow, GameResources.GameFont("Menu"), 515, 90);

        //added by jesse -- gaming page with home button to return home page
        SwinGame.DrawBitmap(GameResources.GameImage("HomeButton"), 685, 70);
    }
Ejemplo n.º 22
0
        protected virtual void InternalRefreshBackingDataList()
        {
            try
            {
                if (m_rawDataListResourceLock.Owned)
                {
                    return;
                }
                if (WorldManager.Instance.IsWorldSaving)
                {
                    return;
                }
                if (WorldManager.Instance.InternalGetResourceLock() == null)
                {
                    return;
                }
                if (WorldManager.Instance.InternalGetResourceLock().Owned)
                {
                    return;
                }

                m_rawDataListResourceLock.AcquireExclusive();

                if (m_backingObject == null)
                {
                    return;
                }
                var rawValue = BaseObject.InvokeEntityMethod(m_backingObject, m_backingSourceMethod);
                if (rawValue == null)
                {
                    return;
                }
                m_rawDataList = UtilityFunctions.ConvertList(rawValue);

                m_rawDataListResourceLock.ReleaseExclusive();
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog.WriteLine(ex);
                m_rawDataListResourceLock.ReleaseExclusive();
            }
        }
Ejemplo n.º 23
0
    void AddNitrousAmt(float amt)
    {
        nitrousAmt = Mathf.Clamp(nitrousAmt + amt, 0, 100);

        float   arcVal = UtilityFunctions.Remap(nitrousAmt, 0, 100, -110, 0);
        Vector3 rot    = nitrousPivot.transform.localEulerAngles;

        rot.z = arcVal;

        Ease easeType = Ease.OutSine;

        if (amt < 0)
        {
            easeType = Ease.Unset;
        }

        nitrousPivot.transform.DOLocalRotate(rot, 1.5f).SetEase(easeType);

        //nitrousText.text = "Nitrous \n" + Mathf.RoundToInt(nitrousAmt).ToString() + "/100";
    }
Ejemplo n.º 24
0
        /// <summary>
        /// Rotates the view by two angles based on mouse movement
        /// </summary>
        private void Rotate(double leftRightAngle, double upDownAngle) // in radians
        {
            var middle   = Center();
            var midpoint = new Point3D(middle.X, middle.Y, middle.Z);
            var axisLR   = -Camera.UpDirection;
            var axisUD   = Vector3D.CrossProduct(Camera.LookDirection, axisLR);

            var rotationLR = new RotateTransform3D(new AxisAngleRotation3D(axisLR, UtilityFunctions.RadiansToDegrees(leftRightAngle)), midpoint);
            var rotationUD = new RotateTransform3D(new AxisAngleRotation3D(axisUD, UtilityFunctions.RadiansToDegrees(upDownAngle)), midpoint);
            var rotation   = new Transform3DGroup()
            {
                Children = new Transform3DCollection()
                {
                    currentTransform, rotationLR, rotationUD
                }
            };

            Camera.Transform     = rotation;
            Camera.LookDirection = middle - new Vector3D(Camera.Position.X, Camera.Position.Y, Camera.Position.Z);
        }
Ejemplo n.º 25
0
        protected void ShowAfterSerializationXml_Click(object sender, EventArgs e)
        {
            //Call DeserializeXml() method to serialize
            Student deserializedStud = UtilityFunctions.DeserializeXml(Server.MapPath(Strings.XmlFilePath));

            //check the status
            if (deserializedStud == null)
            {
                Response.Write(Strings.DeserializationFailed);
            }
            else
            {
                //show object state before serialization
                Response.Write("<h2>Student Object state after XML serialization</h2>");
                Response.Write(string.Format("<br /> Roll No. : {0}", deserializedStud.RollNo));
                Response.Write(string.Format("<br /> Name : {0}", deserializedStud.Name));
                Response.Write(string.Format("<br /> Total Marks : {0}", deserializedStud.TotalMarks));
                Response.Write(string.Format("<br /> Grade : {0}", deserializedStud.Grade));
            }
        }
Ejemplo n.º 26
0
        private void createOutputFile()
        {
            string ext = Path.GetExtension(OutputFile);

            if (ext == ".xlsx")
            {
                CreateExcelFile.CreateExcelDocument(bag.ToList(), OutputFile);
            }
            else
            {
                var xmlOutput = UtilityFunctions.ListToXml(bag.ToList(), "resources");
                File.WriteAllText(OutputFile, xmlOutput.InnerXml, UTF8Encoding.UTF8);
            }

            if (File.Exists(OutputFile) && OpenOutputFileAfterProcess)
            {
                Console.Out.WriteLine("Opening result Excel file (" + OutputFile + ")");
                Process.Start(OutputFile);
            }
        }
Ejemplo n.º 27
0
        public bool WriteRequiredReleasNotes(bool?releaseNoteRequired, string fileName)
        {
            var assets = LinqReleaseNotes.GetAssetsWithReleaseNoteRequired(
                Dictionary.RefinedDictionary, releaseNoteRequired);

            IEnumerable <CReleaseNoteAsset> cReleaseNoteAssets =
                assets as CReleaseNoteAsset[] ?? assets.ToArray();

            if (!UtilityFunctions.IsAny(cReleaseNoteAssets))
            {
                NoAssetsAvailableToPrint(fileName);
                return(false);
            }

            using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(fileName + ".xml"))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("AllReleaseNotes");

                foreach (CReleaseNoteAsset cReleaseNoteAsset in cReleaseNoteAssets)
                {
                    writer.WriteStartElement("ReleaseNote");
                    writer.WriteElementString("ID", cReleaseNoteAsset.Id.ToString());
                    writer.WriteElementString("Name", cReleaseNoteAsset.Name.ToString());
                    writer.WriteElementString("URL", cReleaseNoteAsset.URL.ToString());
                    writer.WriteElementString("ReleaseNoteRequired", cReleaseNoteAsset.ReleaseNoteRequired.ToString());

                    writer.WriteStartElement("Categories");

                    foreach (int i in Dictionary.RefinedDictionary[cReleaseNoteAsset].Keys)
                    {
                        writer.WriteElementString("Category", Dictionary.RefinedDictionary[cReleaseNoteAsset][i]);
                    }
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                writer.WriteEndDocument();
            }
            return(true);
        }
Ejemplo n.º 28
0
        /// <summary>
        ///     Calibrate module temperature by setting offset registers.
        ///     Offsets are subtracted from the measured value to create the reported value.
        ///     Example:  module is actually @ 25C.
        ///     The reported temperature is 35C.
        ///     You would call this method CalibrateModuleTemperature(10.0,10.0)
        /// </summary>
        /// <param name="offsetAt0C"></param>
        /// <param name="offsetAt75C"></param>
        public async Task <bool> CalibrateModuleTemperatureAsync(double offsetAt0C, double offsetAt75C)
        {
            return(await Task.Run(async() =>
            {
                //scale offset temperatures to counts
                var offset0C = BitConverter
                               .GetBytes((short)(offsetAt0C / Qsfp100GRegister.Page4.TemperatureOffset0C.Register.Scale))
                               .Reverse().ToArray();
                var offset75C = BitConverter
                                .GetBytes((short)(offsetAt75C / Qsfp100GRegister.Page4.TemperatureOffset75C.Register.Scale))
                                .Reverse().ToArray();

                // write values and update cal
                await Device.SetRegAsync(Qsfp100GRegister.Page4.TemperatureOffset0C, offset0C);
                await Device.SetRegAsync(Qsfp100GRegister.Page4.TemperatureOffset75C, offset75C);
                await Update_CalibrationAsync().ConfigureAwait(false);


                const int startConfigAddress = 192;
                const int endConfigAddress = 254;
                var writeData = new byte[Qsfp100GRegister.Page4.CiscoSpecificNvr.EndAddress -
                                         Qsfp100GRegister.Page4.CiscoSpecificNvr.StartAddress + 1];
                var readBackData = new byte[Qsfp100GRegister.Page4.CiscoSpecificNvr.EndAddress -
                                            Qsfp100GRegister.Page4.CiscoSpecificNvr.StartAddress + 1];

                var page4Data = GetPage(Memory.Pages.NonVolatile.P4Upper);
                Array.Copy(page4Data, startConfigAddress - 128, writeData, 0, endConfigAddress - startConfigAddress);

                var checkSum = UtilityFunctions.ComputeCheckSum(writeData);
                _ = await Device.SetRegAsync(Qsfp100GRegister.Page4.ModuleConfigCheckSum, checkSum).ConfigureAwait(false);
                await Update_CalibrationAsync().ConfigureAwait(false);

                // validate page 4 upper NVR after device reset.
                //  var res = await DutGpio.Reset(TimeSpan.FromMilliseconds(50), TimeSpan.FromMilliseconds(2500));

                page4Data = GetPage(Memory.Pages.NonVolatile.P4Upper);
                Array.Copy(page4Data, startConfigAddress - 128, readBackData, 0, endConfigAddress - startConfigAddress);

                return readBackData.SequenceEqual(writeData);
            }));
        }
Ejemplo n.º 29
0
    /// <summary>
    /// Draws the game during the attack phase.
    /// </summary>s
    public static void DrawDiscovery()
    {
        const int SCORES_LEFT = 172;
        const int SHOTS_TOP   = 157;
        const int HITS_TOP    = 206;
        const int SPLASH_TOP  = 256;
        const int SCORE_TOP   = 306;
        const int TIMER_LEFT  = 440;
        const int TIMER_TOP   = 85;

        //Show enemy ships
        if ((SwinGame.KeyDown(KeyCode.vk_LCTRL) && SwinGame.KeyDown(KeyCode.vk_v)))
        {
            UtilityFunctions.DrawField(GameController.HumanPlayer.EnemyGrid, GameController.ComputerPlayer, true);
        }

        //Terminate the game directly
        if ((SwinGame.KeyDown(KeyCode.vk_LCTRL) && SwinGame.KeyDown(KeyCode.vk_t)))
        {
            GameController.SwitchState(GameState.EndingGame);
        }


        else
        {
            UtilityFunctions.DrawField(GameController.HumanPlayer.EnemyGrid, GameController.ComputerPlayer, false);
        }

        UtilityFunctions.DrawSmallField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer);
        UtilityFunctions.DrawMessage();


        SwinGame.DrawBitmap(GameResources.GameImage("PauseButton"), 722, 72);

        SwinGame.DrawText(GameController.HumanPlayer.Shots.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, SHOTS_TOP);
        SwinGame.DrawText(GameController.HumanPlayer.Hits.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, HITS_TOP);
        SwinGame.DrawText(GameController.HumanPlayer.Missed.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, SPLASH_TOP);
        SwinGame.DrawText(GameController.HumanPlayer.Score.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, SCORE_TOP);
        SwinGame.DrawText("Time left: ", Color.White, GameResources.GameFont("Menu"), TIMER_LEFT, TIMER_TOP);
        SwinGame.DrawText(GameController.timeCount(480000), Color.White, GameResources.GameFont("MenuMedium"), TIMER_LEFT + 135, TIMER_TOP - 4);
    }
Ejemplo n.º 30
0
    public virtual void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit2D[] hit = Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

            if (hit.Any(x => x.collider is BoxCollider2D && x.transform == transform))
            {
                UtilityFunctions.DebugMessage("Tower selector hit");
                if (IsTowerSelected)
                {
                    IsTowerSelected = false;
                }
                else
                {
                    CloseOtherWindows();
                    IsTowerSelected = true;
                    TowerChoices    = GameObject.FindObjectOfType <TowerTreeScript>().GetUpgradeOptions(TowerType);
                    UtilityFunctions.DebugMessage("TowerChoices: " + TowerChoices.Count);
                }
            }
        }
        if (Target != null)
        {
            if (Time.time >= NextFireTime)
            {
                Fire();
                NextFireTime = Time.time + AttackCooldown;
            }
        }
        else if (Targets.Count > 0)
        {
            Targets.Remove(Target);
        }
        if (Target == null && Targets.Count > 0)
        {
            UtilityFunctions.DebugMessage("Searching for target through update");
            List <Transform> targets = FindClosestTargetsToBase(1);
            Target = targets.Any() ? targets[0] : null;
        }
    }
Ejemplo n.º 31
0
    private void Start()
    {
        if (!Instance)
        {
            Instance = this;
        }

        errorGroup.Deactivate();
        leaveGroup.Deactivate();
    }