Beispiel #1
0
 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;
 }
Beispiel #2
0
 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;
     }
 }
Beispiel #3
0
    void Start()
    {
        enemy_    = Enemy.GetComponent <IEnemy>();
        player_   = PlayableCharacters.GetPlayerInScene();
        playerGO_ = player_.gameObject;
        system_   = GetComponent <ParticleSystem>();

        Timing.RunCoroutine(EmitCo().CancelWith(this.gameObject));
    }
Beispiel #4
0
    private void Start()
    {
        mainCam_ = Camera.main;

        transform_ = transform;
        player_    = GetComponent <PlayableCharacterScript>();
        SceneGlobals.NullCheck(player_);
        map_ = SceneGlobals.Instance.MapScript;

        TrackedPath.Rewind();
    }
Beispiel #5
0
    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);
        }
    }
Beispiel #6
0
    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);
    }
Beispiel #7
0
 void InitializePlayerWithCurrentRunData(PlayableCharacterScript player, CurrentRunData run)
 {
     player.EquipWeapon(run.CurrentWeapon);
     player.MaxLife = run.MaxLife;
     player.Life    = run.Life;
 }