示例#1
0
文件: Gun.cs 项目: gmfk07/Hegemony
 void Start()
 {
     playerStats = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
     cam         = Camera.main;
     ms          = GameObject.Find("Controller").GetComponent <MissionStats>();
     ammoCounter = GameObject.Find("AmmoCounter").GetComponent <Text>();
 }
示例#2
0
    /* Update user's stats for: each level's mission statistics, completion type, time. */
    private static DocumentStore CommitMissionStats(DocumentStore savedStats,
                                                    MissionStats newStats)
    {
        if (savedStats == null)
        {
            Debug.Log("Initializing statistics");
            savedStats = initializeStatistics();
        }

        /* Depending on the new stats' completion type, update it's corresponding counter
         * and total time played.
         */
        IncrementCompletionFor(savedStats, newStats.Type);
        UpdateTime(savedStats, newStats.Time);

        /* Include a new node in the user's stats, such that it records each level's
         * mission statistics, and update its values if necessary.
         */
        DocumentStore levelStats = null;

        if (savedStats.ContainsKey(newStats.LevelID))
        {
            levelStats = savedStats[newStats.LevelID] as DocumentStore;
        }
        savedStats[newStats.LevelID] = CommitLevelStats(levelStats, newStats);

        return(savedStats);
    }
示例#3
0
文件: Player.cs 项目: gmfk07/Hegemony
 private void Start()
 {
     inventory     = gameObject.GetComponent <Inventory>();
     hud           = GameObject.Find("HUD").GetComponent <HUD>();
     ms            = GameObject.Find("Controller").GetComponent <MissionStats>();
     hud.inventory = inventory;
     hud.setUpInventoryEvents();
     fpc = gameObject.GetComponent <FirstPersonController>();
 }
    private static DocumentStore CommitLevelStats(DocumentStore savedStats,
                                                  MissionStats newStats)
    {
        if (savedStats == null)
        {
            Debug.Log("Initializing Level statistics");
            savedStats             = initializeStatistics();
            savedStats["avg_time"] = "0";
        }

        IncrementCompletionFor(savedStats, newStats.Type);
        UpdateTime(savedStats, newStats.Time);

        return(savedStats);
    }
示例#5
0
    //This Function is call when the Logout of the current user. But is doing somethings really strange so don use it

    /*public void Logout(){
     *      if (FirebaseAuth.DefaultInstance.CurrentUser != null){
     *              Debug.Log("Successfully logged Out");
     *              SceneManager.LoadScene("MainMenu");
     *              FirebaseAuth.DefaultInstance.SignOut();
     *      }
     * }*/

    /* Save a
     *
     * Requires the new stats to save as a parameter, which consists of:
     * - Time taken to complete it
     * - Completion type (Rejected, Began, Abandoned, Failed, Completed)
     * - The level's identifier
     */
    public static void SaveMissionStats(MissionStats newStats)
    {
        if (user == null)
        {
            Debug.LogError("A logged in user is required to save mission data.");
            return;
        }

        reference
        .Child("statistics")
        .Child(user.UserId)
        .RunTransaction(
            savedStats => {
            Debug.Log("Running transaction on statistics.");
            savedStats.Value =
                /* Update user's stats for: each level's mission statistics, completion type, time. */
                CommitMissionStats(savedStats.Value as DocumentStore,
                                   newStats);

            return(TransactionResult.Success(savedStats));
        }
            ).ContinueWith(
            task => {
            if (task.IsCanceled)
            {
                Debug.Log("Transaction was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.LogError(
                    "Transaction fault : " +
                    task.Exception.Message
                    );
                Debug.LogError(task.Exception);
                return;
            }
            if (!task.IsCompleted)
            {
                Debug.LogError("Transaction failed to complete.");
                return;
            }
            Debug.Log("Transaction complete.");
        }
            );
    }
示例#6
0
    // Use this for initialization
    void Start()
    {
        missionLogic     = GameObject.Find("Logic").GetComponent <MissionLogic>();
        missionDataStats = GameObject.Find("GameManagerData").GetComponent <MissionStats>();
        getMissionData();

        //stub missions TODO: replace with real missions from data
        //MissionModel[] missions = new MissionModel[] {  new MissionModel {type = MissionType.killTypeOfEnemy , numberToAchive = 5, missionText ="Kill Total of five enemies!", enemyType = EnemyType.General },
        //                                                new MissionModel {type = MissionType.killTypeOfEnemy , numberToAchive = 5, missionText ="Kill five stupid enemies!", enemyType = EnemyType.Stupid },
        //                                                new MissionModel {type = MissionType.getScoreOf , numberToAchive = 10000, missionText ="Get score of 10,000!" }
        //                                                };

        //stub missions
        string title = missionDataStats.getTitle();

        //geting the model from a data object
        missionLogic.setMissions(missions, title);
    }
示例#7
0
    /* Update user's statistics (number of missions completed, total time, avg time per mission) in the DB */
    private static DocumentStore CommitLevelStats(DocumentStore savedStats,
                                                  MissionStats newStats)
    {
        /* Restart user's statistics (missions failed, accepted, etc.)
         * and include "avg_time" key in them.
         */
        if (savedStats == null)
        {
            Debug.Log("Initializing Level statistics");
            savedStats             = initializeStatistics();
            savedStats["avg_time"] = "0";
        }

        /* Depending on the new stats' completion type, update it's corresponding counter
         * and total time played.
         */
        IncrementCompletionFor(savedStats, newStats.Type);
        UpdateTime(savedStats, newStats.Time);

        return(savedStats);
    }
    private static DocumentStore CommitMissionStats(DocumentStore savedStats,
                                                    MissionStats newStats)
    {
        if (savedStats == null)
        {
            Debug.Log("Initializing statistics");
            savedStats = initializeStatistics();
        }

        IncrementCompletionFor(savedStats, newStats.Type);
        UpdateTime(savedStats, newStats.Time);

        DocumentStore levelStats = null;

        if (savedStats.ContainsKey(newStats.LevelID))
        {
            levelStats = savedStats[newStats.LevelID] as DocumentStore;
        }
        savedStats[newStats.LevelID] = CommitLevelStats(levelStats, newStats);

        return(savedStats);
    }
示例#9
0
    // Use this for initialization
    void Start()
    {
        deathLogic   = this.gameObject.GetComponent <DeathLogic>();
        missionStats = GameObject.Find("GameManagerData").GetComponent <MissionStats>();

        enemyKills = new Dictionary <EnemyType, int>     {
            { EnemyType.Stupid, 0 },
            { EnemyType.General, 0 }
        };
        powerUpstaken = new Dictionary <PowerUpType, int>        {
            { PowerUpType.SUPERHIT, 0 }
        };
        MissionsToggleAndText = new InternalMissionModel[] {
            new InternalMissionModel(),
            new InternalMissionModel(),
            new InternalMissionModel()
        };
        TrackTimeForMissionNumber = -1;
        int missionNum = 0;

        //var x = GameObject.Find("PauseMenu/Mission1/Mission1Label").GetComponent<Text>();
        MissionsToggleAndText[missionNum].missionText   = GameObject.Find("PauseMenu/Mission1/Mission1Label").GetComponent <Text>();
        MissionsToggleAndText[missionNum].missionCount  = GameObject.Find("PauseMenu/Mission1/Mission1Count").GetComponent <Text>();
        MissionsToggleAndText[missionNum].missionToggle = GameObject.Find("PauseMenu/Mission1").GetComponent <Toggle>();
        missionNum++;

        MissionsToggleAndText[missionNum].missionText   = GameObject.Find("PauseMenu/Mission2/Mission2Label").GetComponent <Text>();
        MissionsToggleAndText[missionNum].missionToggle = GameObject.Find("PauseMenu/Mission2").GetComponent <Toggle>();
        MissionsToggleAndText[missionNum].missionCount  = GameObject.Find("PauseMenu/Mission2/Mission2Count").GetComponent <Text>();
        missionNum++;

        MissionsToggleAndText[missionNum].missionText   = GameObject.Find("PauseMenu/Mission3/Mission3Label").GetComponent <Text>();
        MissionsToggleAndText[missionNum].missionToggle = GameObject.Find("PauseMenu/Mission3").GetComponent <Toggle>();
        MissionsToggleAndText[missionNum].missionCount  = GameObject.Find("PauseMenu/Mission3/Mission3Count").GetComponent <Text>();
        missionTitle = GameObject.Find("PauseMenu/MissionTitle").GetComponent <Text>();
    }