DEV Community

Akira Game
Akira Game

Posted on

Our game progress ~ Basic Rule ~

Introduction

In the previous posts, I introduced the basic concept of the game and implemented the login screen. From this article onwards, I will introduce the implementation of the main part of the game. We will cover the following topics, each of which is currently under active development.

  • User Animation and Items
  • Timer
  • Basic Rules ( Victory, Defeat )
  • Mirror
  • Mirror Movement ( Through, Break, Trap )

This post will shows the implementation of Basic Rules (Victory and Defeat condition).

Summary of the implementation of Basic Rules.

In our game, players are divided into two teams: Survivor and Hunter. Each team has its own victory and defeat conditions. Below are the conditions for each team, and we implemented the corresponding features accordingly.

Survivor

[Victory]

  • Time up
  • Escape from the exit gate

[Defeat]

  • Killed by Hunters

Hunter

[Victory]

  • Kill Survivor

[Defeat]

  • Survivor escape
  • Time up

Time up

When time runs out, the victory goes to the Survivor side.

The game state is managed by a GameManager script, which we've created to handle states. Whenever each condition is met, this GameManager script is called upon accordingly.

Game Status

We manage game status like the below enum.

public enum GameState
{
  Playing,
  EndingSurvivor,
  EndingHunter
}
Enter fullscreen mode Exit fullscreen mode

When the conditions are met, the game over process is executed as follows.

public void GameOver(string role)
{
  if (status != GameState.EndingHunter && status != GameState.EndingSurvivor)
  {
    switch (role)
    {
      case "Survivor":
        status = GameState.EndingSurvivor;               
        soundManager.gameObject.GetPhotonView().RPC(
          "PlayerBGM",
          RpcTarget.All,
          "Survivor"
        );
        break;
      case "Hunter":
        status = GameState.EndingHunter;                 
        soundManager.gameObject.GetPhotonView().RPC(
          "PlayerBGM",
          RpcTarget.All,
          "Hunter"
         );
         break;
     }
     ListPlayersGet();
  }
}
Enter fullscreen mode Exit fullscreen mode

When time expires, Survivor wins as below video

Escape from the exit gate

When the survivor reach the exit gate, it wins.

As for the process, a 3D collider is set up on the gate itself to trigger a function upon contact. Within that function, the GameManager script is excuted to change the game state. To identify the player as a Survivor, tags are assigned to objects.

private void OnTriggerEnter(Collider other)
{
  PhotonView otherPhotonView = other.GetComponent<PhotonView>();
  if (otherPhotonView != null && otherPhotonView.IsMine)
  {
     if (other.CompareTag("Survivor"))
     {
       gameManger.GameOver("Survivor");
     }
   }
}
Enter fullscreen mode Exit fullscreen mode

When Survivor reach the exit gate, Survivor wins as below video

Kill Survivor

When the Hunter kills the Survivor, it results in victory for the Hunter.
The Survivor has a life value in the process, and when this value reaches zero, the game script is excuted, which lead to Hunter's victory.

Conclusion

Through the implementation, I realized that victory and defeat conditions could potentially change, so it's necessary to implement them in a way that allows for flexible adjustments later on. I've been more used to coding in C# in this regard, and I intend to apply this experience to future game development.

  • User Animation and Items
  • Timer
  • Basic Rules ( Victory, Defeat )
  • Mirror
  • Mirror Movement ( Through, Break, Trap )

Top comments (0)