public IEnumerator LoadPlayerDataFile() { Debug.Log("LoadPlayerData start"); string playerDataText = null; // loading from persistent data string filePath = Application.persistentDataPath + "/PlayerBlob.json"; if (File.Exists(filePath)) { _fileWWW = new WWW("file://" + filePath); yield return(_fileWWW); if (_fileWWW.bytes.Length > 0) { playerDataText = _fileWWW.text; } _playerBlob = (PlayerBlob)Serializer.Deserialize(typeof(PlayerBlob), playerDataText); } // first time load else { _playerBlob = PlayerBlob.NewPlayerBlob(); } Debug.Log("LoadPlayerData done!"); }
internal void RemoveBlob(PlayerBlob blob) { lock (BlobsLock) { _blobs.Remove(blob); } }
internal void AddBlob(PlayerBlob blob) { lock (BlobsLock) { _blobs.Add(blob); } }
private void ApplyPlayerDecisions() { lock (BlobsListLock) { foreach (var player in _playerRepository.Players) { if (player.Join) { var position = RemoveFoodAndGetSpawnPosition(); var playerBlob = new PlayerBlob(player, this, _physics, _stateTracker, position, true); AddBlob(playerBlob); player.Join = false; continue; } if (!player.Blobs.Any()) { continue; } var center = DetermineGoosCenter(player.Blobs); var direction = player.PlayerDecisions.Velocity; foreach (var blob in player.Blobs.Where(x => x.ControlledByPlayer)) { var normalizedVelocity = (center + direction - blob.Position).Normalize(); var speed = Math.Min(direction.Length, PlayerBlob.GetMaxSpeed(blob.Mass)); blob.Velocity = normalizedVelocity * speed; switch (player.PlayerDecisions.Activity) { case Activity.None: break; case Activity.Split: blob.Split(); break; case Activity.EjectMass: blob.EjectMass(); break; default: throw new ArgumentOutOfRangeException(); } } player.PlayerDecisions.Activity = Activity.None; } } }
void Start() { // :) playerScript = GameObject.Find("Player").GetComponent <PlayerBlob>(); dialogues = GameObject.FindGameObjectsWithTag("Dialogue"); if (Instance) { Destroy(Instance); } Instance = this; }
public static PlayerBlob NewPlayerBlob() { PlayerBlob blob = new PlayerBlob() { CharacterBlobSlots = new Dictionary <string, CharacterBlob>() }; for (int i = 0; i < TuningData.Instance.NumSaveSlots; i++) { blob.CharacterBlobSlots.Add(SLOT_PREFIX + i, null); } return(blob); }
public void Init() { Input.ClearBindings(); var player = new PlayerBlob(Color.Red); var enemies = new List <EnemyBlob> { new EnemyBlob(), new EnemyBlob(), new EnemyBlob(), new EnemyBlob() }; var gameBackground = new GameBackground(); _visuals.Add(player); _visuals.AddRange(enemies); _visuals.Add(gameBackground); _automatons.Add(player); _automatons.AddRange(enemies); _automatons.Add(gameBackground); }
public void Init() { World.PlayMusic("Music/thechase"); Input.ClearBindings(); Input.OnDirection(UpdateCamera); _camera = new Camera(new Vector2(775, 425)); var player = new PlayerBlob(Color.Red); var enemies = new List <EnemyBlob> { new EnemyBlob(), new EnemyBlob(), new EnemyBlob(), new EnemyBlob() }; var gameBackground = new GameBackground(); _visuals.Add(gameBackground); _visuals.Add(player); _visuals.AddRange(enemies); _automatons.Add(gameBackground); _automatons.Add(player); _automatons.AddRange(enemies); }