Example #1
0
    void Start()
    {
        highScore = PlayerPrefs.GetInt("highScore");
        if ((pro == null) && (GetComponent <ThePlayer>() != null))
        {
            pro = GetComponent <ThePlayer>();
        }
        else
        {
            Debug.LogWarning("Missing ThePlayer component. Please add one");
        }

        sceneNo = SceneManager.GetActiveScene().buildIndex;
        // Lcomplete = GetComponent<App_Initialize>();
        if (sceneNo == 0)
        {
            increaser = 150;
        }
        if (sceneNo == 1)
        {
            increaser = 200;
        }
        if (sceneNo == 2)
        {
            increaser = 250;
        }

        if (sceneNo == 0 && PlayerPrefs.GetInt("level") != 1 && PlayerPrefs.GetInt("level") != 2)
        {
            PlayerPrefs.SetInt("level", 0);
        }
        // else if(keyPresent == false){
        //     PlayerPrefs.SetInt("level", 0);
        // }
    }
 private void StartGame()
 {
     _gameHud.StartGame();
     _loadScreen.HideLoadScreen();
     GameMusic.PlaySound(GameMusicControl.GameTrack.Twinkly);
     ThePlayer.SetMovementMode(FlapComponent.MovementMode.VerticalOnly);
 }
        public HighScoreWindow(int score)
        {
            InitializeComponent();

            player = new ThePlayer(score);
            textBlock.Text = textBlock.Text + score + " points!";
        }
Example #4
0
    void OnPlayerCreation(Notification n)
    {
        int spawnAngle  = 0;
        int playerLabel = 0;

        int traitor = Random.Range(0, 4);

        for (int i = 0; i < numberOfPlayers; i++)
        {
            ThePlayer newPlayer = new ThePlayer();
            newPlayer.HP            = maxPlayerHP;
            newPlayer.fireRate      = defaultFireRate;
            newPlayer.movementSpeed = defaultMovementSpeed;

            if (i == traitor)
            {
                newPlayer.isTraitor = true;
            }
            else
            {
                newPlayer.isTraitor = false;
            }

            newPlayer.player = Instantiate(playerPrefab, spawnCentre);

            newPlayer.player.transform.localPosition = new Vector3(playerSpawnRange, 0, 0);
            spawnAngle += 90;
            spawnCentre.transform.Rotate(new Vector3(0, spawnAngle, 0));

            newPlayer.player.transform.SetParent(playerContainer);
            newPlayer.player.transform.name = playerLabel.ToString();

            PlayerDict.Add((playerLabel++).ToString(), newPlayer);
        }
    }
Example #5
0
        /// <summary>
        /// Draw the map
        /// </summary>
        public void Draw()
        {
            Console.Clear();
            var origRow = Console.CursorTop;
            var origCol = Console.CursorLeft;

            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    Tiles[y, x].Draw();
                }
                Console.WriteLine();
            }
            Console.WriteLine($"Player {ThePlayer.Number} location: [{ThePlayer.X + 1}, {ThePlayer.Y + 1}]");

            ThePlayer.Draw();

            foreach (var m in Monsters)
            {
                m.Draw();
            }

            Console.SetCursorPosition(0, 0);
            foreach (var m in Monsters)
            {
                m.PerformAI();
            }
        }
    public override void Collision(Collision2D other)
    {
        ThePlayer.DeactivateRush();

        if (other.collider.name == "StalObject")
        {
            other.collider.GetComponentInParent <Stalactite>().Crack();
        }

        if (ThePlayer.ActivateShield())
        {
            ThePlayer.PlaySound(ClumsyAudioControl.PlayerSounds.Collision); // TODO sounds
        }
        else
        {
            if (other.collider.name == "StalObject")
            {
                GameData.Instance.Data.Stats.ToothDeaths++;
            }
            else
            {
                //Level.Stats.RockDeaths++; // TODO check for other objects
            }
            ThePlayer.PlaySound(ClumsyAudioControl.PlayerSounds.Collision);
            ThePlayer.Die();
        }
    }
Example #7
0
 private void ResumeGameplay()
 {
     _bPaused = false;
     ThePlayer.PauseGame(false);
     _gameHud.HideResumeTimer();
     _gameHud.GamePaused(false);
     PlayerController.ResumeGameplay();
 }
 protected override void AddDistance(float dist)
 {
     if (_caveHandler.IsGnomeEnding() && Level.AtCaveEnd() || !ThePlayer.GameHasStarted())
     {
         return;
     }
     base.AddDistance(dist);
 }
Example #9
0
 public override void PauseGame(bool showMenu)
 {
     _bPaused = true;
     ThePlayer.PauseGame(true);
     _gameHud.GamePaused(true);
     if (showMenu)
     {
         _gameMenu.PauseGame();
     }
 }
 private void ResumeGameplay()
 {
     EventListener.ResumeGame();
     Toolbox.Instance.GamePaused = false;
     GameState = GameStates.Normal;
     ThePlayer.PauseGame(false);
     _gameHud.HideResumeTimer();
     _gameHud.GamePaused(false);
     PlayerController.ResumeGameplay();
 }
 private void CreateNewManager(object sender, RoutedEventArgs e)
 {
     Person manager = new Person()
     {
         Name         = this.Name_TextBox.Text,
         Surname      = this.Surname_TextBox.Text,
         BirthdayDate = this.Birthday_DatePicker.SelectedDate.Value,
         Type         = Person.PersonType.Manager,
     };
     ThePlayer player = new ThePlayer();
 }
Example #12
0
        private static void PlayerTryMoveOffsetTo(int xoffset, int yoffset)
        {
            //this is the proposed new x,y of the player if move is successful.
            int newx = ThePlayer.X + xoffset;
            int newy = ThePlayer.Y + yoffset;

            //perform boundary checking of new location, if it fails then we can't move there just because of boundary issues
            if (newx > -1 && newx < Width && newy > -1 && newy < Height)
            {
                //get the tile that is at the new location
                MapTile t = GetTileAtPos(newx, newy);

                //if the space moving upwards is a blank space then move up
                if (t.IsWalkable)
                {
                    ThePlayer.Dirty = true;
                    Tiles[ThePlayer.Y, ThePlayer.X].IsWalkable = true;  //the space we just moved from
                    ThePlayer.LastX = ThePlayer.X;
                    ThePlayer.LastY = ThePlayer.Y;
                    ThePlayer.X     = newx;
                    ThePlayer.Y     = newy;
                    Tiles[ThePlayer.Y, ThePlayer.X].IsWalkable = false; //make new tile not walkable because you are on it

                    CheckTileForAction(ThePlayer.X, ThePlayer.Y);
                }
                else
                {
                    //if we can't walk onto this space then what is in this space? a wall, door, monster, etc.?
                    //walls do nothing, doors we can check for keys, monsters we attack.
                    var type = GetTileAtPos(newx, newy).GetType();
                    if (type == typeof(MapTileWall))
                    {
                        //do nothing, its a wall
                    }
                    else if (type == typeof(MapTileSpace))
                    {
                        //so if its a space and its not walkable, probably a monster here.
                        var monster = MonsterMgr.GetMonsterAt(newx, newy);
                        if (monster.IsAlive)
                        {
                            var maxdamage = ThePlayer.CanDealDamage();
                            //lets hit the monster for damage
                            monster.TakeDamage(maxdamage);
                            MessageBrd.Add($"Monster took {maxdamage} damage.");
                            if (!monster.IsAlive)
                            {
                                MessageBrd.Add($"Monster is DEAD!");
                            }
                            MonsterMgr.PruneDeadMonsters();
                        }
                    }
                }
            } // end of map boundary check
        }
 private void Update()
 {
     if (ThePlayer.IsAlive() && !Level.AtCaveEnd())
     {
         AddDistanceFromTime(Time.deltaTime);
     }
     if (PlayerController.State == GameStates.Normal && Level.AtCaveEnd())
     {
         ThePlayer.CaveEndReached();
     }
 }
Example #14
0
 /*
  * @name    CastPlayer()
  * @purpose This downcasts the correct player to wether or not it is a human or computer.
  *
  * @return  bool
  */
 public void CastPlayer()
 {
     if (ThePlayer.GetType() == typeof(Human))
     {
         ThePlayer = (Human)ThePlayer;
     }
     else
     {
         ThePlayer = (Computer)ThePlayer;
     }
 }
Example #15
0
 public void MovePlayer(Point point)
 {
     if ((point.X < BoardWidth - 1 && point.X > 0) && (point.Y < BoardHeight - 1 && point.Y > 0))
     {
         ThePlayer.Move(point);
     }
     else
     {
         EndGame("You collided with the wall!");
     }
 }
 public override void PauseGame(bool showMenu)
 {
     EventListener.PauseGame();
     Toolbox.Instance.GamePaused = true;
     GameState = GameStates.Paused;
     ThePlayer.PauseGame(true);
     _gameHud.GamePaused(true);
     if (showMenu)
     {
         _gameMenu.PauseGame();
     }
 }
Example #17
0
 public void CheckCollisions()
 {
     if (PlayerOnFood())
     {
         Score += 100;
         SpawnFood();
         ThePlayer.Grow();
     }
     else if (PlayerOnPlayer())
     {
         EndGame("You collided with yourself!");
     }
 }
    private IEnumerator BossEntrance()
    {
        _state = BossGameState.InBossRoom;
        ThePlayer.EnableHover();

        FindObjectOfType <SlidingDoors>().Close();

        // TODO boss entrance sequence
        yield return(new WaitForSeconds(2f));

        ThePlayer.DisableHover();
        BossEvents.BossFightStart();
    }
Example #19
0
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            base.OnNavigatedFrom(e);
            var vm = DataContext as VideoPlayerViewModel;

            if (vm != null)
            {
                vm.VideoStream = null;
            }

            ThePlayer.Dispose();
            HlsPlayer.Dispose();
        }
    private IEnumerator LoadSequence()
    {
        yield return(new WaitForSeconds(1f));

        StartGame();
        yield return(ThePlayer.StartCoroutine("CaveEntranceAnimation"));

        // TODO put this into a function that says "boss level begin" or something
        GameState = GameStates.Normal;
        _state    = BossGameState.MovingTowardsBoss;
        ThePlayer.SetPlayerSpeed(Toolbox.Instance.LevelSpeed);
        PlayerController.EnterGamePlay();
    }
        public override bool FireEvent(Event E)
        {
            if (E.ID == "IdleQuery")
            {
                GameObject GO = E.GetParameter <GameObject>("Object");

                // Check if the bed has an owner.
                if (owner != string.Empty)
                {
                    bool result = false;

                    // Allow the owner to use 'owner' labeled beds.
                    if (GO.Blueprint == owner)
                    {
                        result = true;
                    }

                    // Allow the faction to use 'faction' labeled beds.
                    foreach (KeyValuePair <string, int> item in GO.pBrain.FactionMembership)
                    {
                        if (item.Key == owner)
                        {
                            result = true;
                        }
                    }

                    // Stop the usage of the bedroll if this is not an owner.
                    if (result == false)
                    {
                        return(result);
                    }
                }

                // Debugging
                if (debug)
                {
                    string message = GO.DisplayName + " goes to bed!";
                    MessageQueue.AddPlayerMessage(message);
                }
            }
            if (E.ID == "CommandSmartUse" && !ThePlayer.HasEffect("Sitting"))
            {
                // Check if the bed has an owner.
                if (owner != string.Empty)
                {
                    Popup.Show("The owner of this bed would be very cross if they caught you sleeping in it!");
                    return(false);
                }
            }
            return(base.FireEvent(E));
        }
        /// <summary>
        /// Add the player to the high scorers list.
        /// Then uses the selection sort to sort the list.
        /// </summary>
        /// <param name="player"></param>
        private void AddPlayerToList(ThePlayer player)
        {
            // Keep adding players until the list is full
            if (currentIndex < highestPlayers.Length)
            {
                highestPlayers[currentIndex] = player;
                currentIndex++;
            }
            // Once the list is full then lets find the player with the lowest score
            // and replace them the with newest score.
            else if (currentIndex == highestPlayers.Length)
            {
                int lowestIndex = 0;
                for (int i = 0; i < highestPlayers.Length; i++)
                {
                    if (highestPlayers[i].Score < highestPlayers[lowestIndex].Score)
                    {
                        lowestIndex = i;
                    }
                }

                if (highestPlayers[lowestIndex].Score < player.Score)
                {
                    highestPlayers[lowestIndex] = player;
                }
            }

            // SELECTION SORT //
            ThePlayer tmp;
            int min = 0;

            for (int j = 0; j < highestPlayers.Length - 1; j++)
            {
                min = j;
                if (highestPlayers[j] != null)
                {
                    for (int k = j + 1; k < highestPlayers.Length; k++)
                    {
                        if (highestPlayers[k] != null && highestPlayers[k].Score > highestPlayers[min].Score)
                        {
                            min = k;
                        }
                    }

                    tmp = highestPlayers[min];
                    highestPlayers[min] = highestPlayers[j];
                    highestPlayers[j] = tmp;
                }
            }
        }
    private IEnumerator LevelStartAnimation()
    {
        yield return(new WaitForSeconds(LevelStartupTime));

        Level.GameMenu.RemoveLoadingOverlay();
        yield return(null);

        ThePlayer.StartFog();
        ThePlayer.StartCoroutine("CaveEntranceAnimation");

        const float timeToReachDest = 0.6f;

        yield return(new WaitForSeconds(timeToReachDest));

        LevelStart();
    }
    private IEnumerator UpdateResumeTimer()
    {
        float waitTime = Level.GameMenu.RaiseMenu();

        yield return(new WaitForSeconds(waitTime));

        _resumeTimerStart = Time.time;

        while (ThePlayer.IsAlive() && _resumeTimerStart + ResumeTimer - waitTime > Time.time)
        {
            float timeRemaining = _resumeTimerStart + ResumeTimer - Time.time;
            Level.GameHud.SetResumeTimer(timeRemaining);
            yield return(null);
        }
        ResumeGameplay();
    }
    public override void TriggerEntered(Collider2D other)
    {
        switch (other.name)
        {
        case "MothTrigger":
            other.GetComponentInParent <Moth>().ConsumeMoth();
            break;

        case "ExitTrigger":
            ThePlayer.ExitAutoFlightReached();
            break;

        case "Spore":
            ThePlayer.Fog.Minimise();
            break;
        }
    }
Example #26
0
    void BuffStats(float buff, ThePlayer thisPlayer)
    {
        float      ms     = defaultMovementSpeed * buff;
        float      fr     = defaultFireRate * buff;
        GameObject player = PlayerDict[name].player;
        bool       it     = PlayerDict[name].isTraitor;

        PlayerDict.Remove(thisPlayer.player.name);

        ThePlayer newPlayer = new ThePlayer();

        newPlayer.player        = player;
        newPlayer.movementSpeed = ms;
        newPlayer.fireRate      = fr;
        newPlayer.isTraitor     = it;

        PlayerDict.Add(thisPlayer.player.name, newPlayer);
    }
Example #27
0
        public Game1()
        {
            Graphics = new GraphicsDeviceManager(this);
            Graphics.IsFullScreen = false;
            Graphics.SynchronizeWithVerticalRetrace = true;
            Graphics.GraphicsProfile           = GraphicsProfile.HiDef;
            Graphics.PreferredBackBufferWidth  = 1200;
            Graphics.PreferredBackBufferHeight = 900;
            Graphics.PreferMultiSampling       = true; //Error in MonoGame 3.6 for DirectX, fixed for dev version.
            Graphics.PreparingDeviceSettings  += SetMultiSampling;
            Graphics.ApplyChanges();
            Graphics.GraphicsDevice.RasterizerState = new RasterizerState(); //Must be after Apply Changes.
            IsFixedTimeStep       = false;
            Content.RootDirectory = "Content";

            FPSTimer = new Timer(this, 1);

            Player     = new ThePlayer(this);
            Background = new Background(this, Player);
            Enemies    = new EnemyControl(this, Player);
            Houses     = new HouseControl(this, Player);
        }
    private void MoveClumsy(float time)
    {
        const float manualCaveScale = 0.8558578f;
        float       distToTravel    = Toolbox.TileSizeX * manualCaveScale + 1f;

        if (ThePlayer.IsPerched())
        {
            return;
        }
        float dist = time * ThePlayer.GetPlayerSpeed();

        if (_distTravelled + dist > distToTravel)
        {
            dist = distToTravel - _distTravelled;
            ThePlayer.SetMovementMode(FlapComponent.MovementMode.HorizontalEnabled);
            StartCoroutine("BossEntrance");
        }
        _distTravelled += dist;
        ThePlayer.transform.position         += Vector3.right * dist;
        _playerCam.transform.position        += Vector3.right * dist;
        ThePlayer.Lantern.transform.position += Vector3.right * dist;
    }
    /* Monitor enemy alive states */
    void Update()
    {
        bool      anyAlive   = false;
        bool      anySpawned = false;
        ThePlayer playerRef  = null;

        foreach (EnemyAI anEnemy in levelEnemies)
        {
            if (anEnemy != null)
            {
                anySpawned = true;
            }
            if (anEnemy != null && !anEnemy.isDead)
            {
                anyAlive = true;
            }
            if (anEnemy != null)
            {
                playerRef = anEnemy.player.GetComponent <ThePlayer>();
            }
        }
        if (!anyAlive)
        {
            ScoreManager.Instance.FreezeScore();
        }
        if (!anySpawned)
        {
            ScoreManager.Instance.ShowNextLevelPrompt();
            foreach (GameObject bullet in GameObject.FindGameObjectsWithTag("Bullet"))
            {
                Destroy(bullet);
            }
        }
        if (playerRef != null)
        {
            playerRef.isInvincible = !anyAlive;
        }
    }
Example #30
0
        /// <summary>
        /// Draw the map
        /// </summary>
        public int Update()
        {
            var origRow = Console.CursorTop;
            var origCol = Console.CursorLeft;

            if (NeedsRedrawing)
            {
                Console.Clear();

                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        Tiles[y, x].Draw();
                    }
                    Console.WriteLine();    //carriage return at end of each line because we're not using SetCursorPosition.
                }
                NeedsRedrawing = false;
            }

            //if there is a keypress available to capture, take it and perform its action
            if (Console.KeyAvailable)
            {
                var ch = Console.ReadKey(true).Key;
                switch (ch)
                {
                case ConsoleKey.Escape:
                    Log.Information("User is quitting.");
                    return(-1);

                case ConsoleKey.UpArrow:
                    //perform boundary checking
                    if (ThePlayer.X > 0)
                    {
                        //if the space moving upwards is a blank space then move up
                        if (GetTileAtPos(ThePlayer.X, ThePlayer.Y - 1).IsWalkable)
                        {
                            MovePlayer(PlayerMovement.Up);
                        }
                    }
                    break;

                case ConsoleKey.DownArrow:
                    if (ThePlayer.Y < Height - 1)
                    {
                        if (GetTileAtPos(ThePlayer.X, ThePlayer.Y + 1).IsWalkable)
                        {
                            MovePlayer(PlayerMovement.Down);
                        }
                    }
                    break;

                case ConsoleKey.RightArrow:
                    if (ThePlayer.X < Width - 1)
                    {
                        if (GetTileAtPos(ThePlayer.X + 1, ThePlayer.Y).IsWalkable)
                        {
                            MovePlayer(PlayerMovement.Right);
                        }
                    }
                    break;

                case ConsoleKey.LeftArrow:
                    if (ThePlayer.X > 0)
                    {
                        if (GetTileAtPos(ThePlayer.X - 1, ThePlayer.Y).IsWalkable)
                        {
                            MovePlayer(PlayerMovement.Left);
                        }
                    }
                    break;
                }
            }


            //foreach player in players coming soon....
            ThePlayer.Update();

            MonsterMgr.UpdateAll(this);

            MessageBrd.Update();

            Console.SetCursorPosition(0, 0);

            return(0);
        }
Example #31
0
    // ------------------------------------------------------------------------------------------------------

    // Called from Unity when player clicks on this floor tile
    public void OnMouseUpAsButton()
    {
        // Pathfind to this clicked floor tile.
        ThePlayer.PathfindToFloorTile(this);
    }
Example #32
0
        /// <summary>
        /// Draw the map
        /// </summary>
        static public int Update()
        {
            if (ThePlayer.Life < 1)
            {
                Console.Clear();
                MessageBrd.Add($"You have DIED!");
                MessageBrd.Update();
                return(-1);
            }

            var origRow = Console.CursorTop;
            var origCol = Console.CursorLeft;

            UpdateFogOfWar();

            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    Tiles[y, x].Draw();
                }
            }
            Dirty = false;

            //foreach player in players coming soon....
            ThePlayer.Update();

            MonsterMgr.UpdateAll();

            MessageBrd.Update();

            ScoreCard.Update();


            //if there is a keypress available to capture, take it and perform its action
            if (Console.KeyAvailable)
            {
                var ch = Console.ReadKey(true).Key;
                switch (ch)
                {
                case ConsoleKey.Escape:
                    Log.Information("User is quitting.");
                    return(-1);

                case ConsoleKey.F2:
                    CheatToggleFOW();
                    break;

                case ConsoleKey.UpArrow:
                    PlayerTryMoveOffsetTo(0, -1);
                    break;

                case ConsoleKey.DownArrow:
                    PlayerTryMoveOffsetTo(0, 1);
                    break;

                case ConsoleKey.RightArrow:
                    PlayerTryMoveOffsetTo(1, 0);
                    break;

                case ConsoleKey.LeftArrow:
                    PlayerTryMoveOffsetTo(-1, 0);
                    break;
                }
            }

            //Console.SetCursorPosition(0, 0);

            return(0);
        }