Exemplo n.º 1
0
 public void Init(Player.Gender gender)
 {
     RandomHelper.r = new System.Random(10000);
     phase          = 0;
     CreatePlayer(gender);
     allCards = GetCards();
     allTexts = GetTexts();
     CloseWebsocket();
 }
Exemplo n.º 2
0
    void SetSelectedCharacter(Player.Gender gender)
    {
        tmpGender = gender;

        if (tmpGender == Player.Gender.Female)
        {
            Selected = false;
            An.SetTrigger("SelectFemale");
        }
        else
        {
            Selected = true;
            An.SetTrigger("SelectMale");
        }

        SoundManager.instance.PlaySingle(switchSelection);
    }
Exemplo n.º 3
0
        public GameScreen(Game1 game, Player.Gender gender) : base(game)
        {
            GameManager.Instance.GameScreen = this;

            gameObjects.Add(new Bed(new Vector2(974, 396)));
            gameObjects.Add(new Toilet(new Vector2(125, 400)));
            gameObjects.Add(new Food(new Vector2(500, 371)));

            _radio = new Radio(new Vector2(680, 384));
            gameObjects.Add(_radio);

            gameObjects.Add(new Sink(new Vector2(335, 387)));

            gameObjects.Add(new GameBounds(new Rectangle(0, 0, GameConstants.GameWidth, 490)));
            gameObjects.Add(new GameBounds(new Rectangle(0, 0, 129, GameConstants.GameHeight)));
            gameObjects.Add(new GameBounds(new Rectangle(0, 650, GameConstants.GameWidth, 156)));
            gameObjects.Add(new GameBounds(new Rectangle(1150, 0, 305, GameConstants.GameHeight)));
            gameObjects.Add(new GameBounds(new Rectangle(436, 0, 50, 530)));
            gameObjects.Add(new GameBounds(new Rectangle(436, 600, 50, 530)));

            Player = new Player(gender);

            UiComponents.Add(new TextPopup(RoomName, true));

            UiComponents.Add(new StatusBar(new Vector2(20, GameConstants.GameHeight - 50), "Health",
                                           StatusBar.StatusType.Health));
            UiComponents.Add(new StatusBar(new Vector2(130, GameConstants.GameHeight - 50), "Sanity",
                                           StatusBar.StatusType.Sanity));
            UiComponents.Add(new StatusBar(new Vector2(240, GameConstants.GameHeight - 50), "Hunger",
                                           StatusBar.StatusType.Hunger));
            UiComponents.Add(new StatusBar(new Vector2(350, GameConstants.GameHeight - 50), "Thirst",
                                           StatusBar.StatusType.Thirst));
            UiComponents.Add(new StatusBar(new Vector2(460, GameConstants.GameHeight - 50), "Bladder",
                                           StatusBar.StatusType.Bladder));

            _pauseButtons.Add(new Button("continue", new Vector2(GameConstants.GameWidth / 2 + 10 - ContentManager.Instance.Fonts[ContentManager.FontTypes.Ui].MeasureString("continue").X / 2, GameConstants.GameHeight / 2), Color.Black * 0, Color.White, Button.ButtonTag.Start));
            _pauseButtons.Add(new Button("quit", new Vector2(GameConstants.GameWidth / 2 + 10 - ContentManager.Instance.Fonts[ContentManager.FontTypes.Ui].MeasureString("quit").X / 2, GameConstants.GameHeight / 2 + 80), Color.Black * 0, Color.White, Button.ButtonTag.Finish));

            UiComponents.Add(new TextPopup("Day " + ++GameManager.Instance.CurrentDay, true));

            MediaPlayer.Volume      = GameConstants.MusicLevel;
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Play(ContentManager.Instance.Theme);
        }
Exemplo n.º 4
0
 private static Player CreatePlayer(string gender, string name)
 {
     Player.Gender gender_enum = gender.ToUpper().Equals("M") ? Player.Gender.Male : Player.Gender.Female;
     return(new Player(gender_enum, name));
 }
Exemplo n.º 5
0
 void CreatePlayer(Player.Gender gender)
 {
     Player = new Player(gender);
 }
Exemplo n.º 6
0
    public async Task <GameData> Load(string GUID, bool isConversionLoad = false)
    {
        try
        {
            Debug.Log("Deserializing data... " + GUID);
            if (!File.Exists(Application.persistentDataPath
                             + $"/Saves/{GUID}/save.dat"))
            {
                Debug.LogWarning("Save file does not exist or no save file specified");
                throw new Exception("Save file does not exist or no save file specified");
            }
            // Deserialize game file
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file =
                File.OpenRead(Application.persistentDataPath
                              + $"/Saves/{GUID}/save.dat");
            GameData deserializedData = (GameData)bf.Deserialize(file);
            file.Close();
            Debug.Log("Game data deserialized!");

            Debug.Log("Checking for game save format updates...");
            if (!isConversionLoad && deserializedData.GameMetadata.SaveVersion != new GameMetadata().SaveVersion)
            {
                await Convert(GUID, deserializedData.GameMetadata.SaveVersion);

                Debug.Log("Old format detected! Converting...");
            }
            else
            {
                Debug.Log("No conversions needed");
            }

            Debug.Log("Copying object data...");
            GameMetadata    = deserializedData.GameMetadata;
            PlayerGender    = deserializedData.PlayerGender;
            Days            = deserializedData.Days;
            InDebt          = deserializedData.InDebt;
            Money           = deserializedData.Money;
            BorrowedMoney   = deserializedData.BorrowedMoney;
            BorrowLimit     = deserializedData.BorrowLimit;
            Weather         = deserializedData.Weather;
            StorylinesSeen  = deserializedData.StorylinesSeen;
            ShopItemLevels  = deserializedData.ShopItemLevels;
            FlowerBedStates = deserializedData.FlowerBedStates;
            Debug.Log("Object data copied!");

            return(this);
        }
        catch (Exception e)
        {
            Debug.LogError(e);
            Debug.LogError("Failed to deserialize save!");

            Debug.Log("Saving loaded data and creating backup copy");
            Save(true, "load_failure_backup").Wait(); // this will create a backup of the old corrupted copy and by saving, we create a fresh save that will likely work

            return(new GameData()
            {
                GameMetadata = new GameMetadata()
                {
                    GUID = Guid.NewGuid().ToString(),
                    SaveName = "Corrupted Or Missing Save"
                }
            });
        }
    }
Exemplo n.º 7
0
 void CreateNewPlayer(Player.Gender gender)
 {
     GameManager.Instance.Init(gender);
 }