void SavePlayerDataInCurrentRun(PlayableCharacterScript player, CurrentRunData run) { // Remember player stats since player object is destroyed when loading next level run.CurrentWeapon = player?.CurrentWeapon?.Id ?? WeaponIds.Rifle; run.MaxLife = player.MaxLife; run.Life = player.Life; }
void AdvanceCurrentRun(CurrentRunData run, PlayableCharacterScript player) { // Advance progress. if (run.SpecialLocation == SpecialLocation.BossWorld1) { // World1 complete, move to world 2 (but first a visit to the shop) run.FloorInWorld = 1; run.World = World.World2; run.SpecialLocation = SpecialLocation.Shop; run.ShopKeeperPokeCount = 0; // Start over poke count when changing world } else if (run.SpecialLocation == SpecialLocation.Shop) { run.SpecialLocation = SpecialLocation.None; } else if (run.World == World.World2 && run.FloorInWorld > 1) { run.FloorInWorld = 1; run.World = World.World3; run.SpecialLocation = SpecialLocation.Shop; run.ShopKeeperPokeCount = 0; } else if (run.SpecialLocation == SpecialLocation.None) { // Just completed a standard floor. run.FloorInWorld++; run.TotalFloor++; run.SpecialLocation = SpecialLocation.Shop; } else { run.SpecialLocation = SpecialLocation.None; } }
void Start() { enemy_ = Enemy.GetComponent <IEnemy>(); player_ = PlayableCharacters.GetPlayerInScene(); playerGO_ = player_.gameObject; system_ = GetComponent <ParticleSystem>(); Timing.RunCoroutine(EmitCo().CancelWith(this.gameObject)); }
private void Start() { mainCam_ = Camera.main; transform_ = transform; player_ = GetComponent <PlayableCharacterScript>(); SceneGlobals.NullCheck(player_); map_ = SceneGlobals.Instance.MapScript; TrackedPath.Rewind(); }
void CreatePlayer(Vector3 position) { string characterTag = CurrentRunData.Instance.StartingCharacterTag; var player = PlayableCharacters.Instance.InstantiateCharacter(characterTag, position); player.transform.SetParent(DynamicObjectRoot); playerScript_ = player.GetComponent <PlayableCharacterScript>(); if (!CurrentRunData.Instance.HasPlayerData) { // Initialize current run if game is started directly from this scene, and not from camp CurrentRunData.StartNewRun(); SavePlayerDataInCurrentRun(playerScript_, CurrentRunData.Instance); CurrentRunData.Instance.HasPlayerData = true; CurrentRunData.StoreState(); } else { InitializePlayerWithCurrentRunData(playerScript_, CurrentRunData.Instance); } }
public bool SetCharacterToHumanControlled(string characterTag, bool showChangeEffect = false) { var toBeControlled = GameObject.FindWithTag(characterTag)?.GetComponent <PlayableCharacterScript>(); SceneGlobals.NullCheck(toBeControlled, "toBeControlled"); var alreadyControlled = playerInScene_; bool noChange = alreadyControlled?.tag == toBeControlled.tag; if (noChange) { return(false); } alreadyControlled?.SetIsHumanControlled(false); toBeControlled.SetIsHumanControlled(true, constraints: RigidbodyConstraints2D.FreezeRotation, showChangeEffect); playerInScene_ = toBeControlled; return(true); }
void InitializePlayerWithCurrentRunData(PlayableCharacterScript player, CurrentRunData run) { player.EquipWeapon(run.CurrentWeapon); player.MaxLife = run.MaxLife; player.Life = run.Life; }