Example #1
0
 /*
  * Creator: Shane Weerasuriya, Myles Hangen
  * Initiate a new game and load the first level
  */
 public void StartNewGame()
 {
     AllConditions.Instance.Reset();
     AllEventList.changeStatus("villageInitial", 0, false);
     GlobalControl.Instance.newSceneID = 0;
     SceneManager.LoadSceneAsync(9, LoadSceneMode.Single);
 }
Example #2
0
 // Use this for initialization
 void Start()
 {
     dialogArray   = GetComponent <DialogArray> ();
     dialogManager = FindObjectOfType <DialogueManagerTwo> ();
     if (!AllEventList.returnStatus("villageInitial", 0))
     {
         dialogManager.StartDialogue(dialogArray.conversations[0]);
     }
 }
Example #3
0
 /*Set up the portal interface butons base on the staus in the all event
  * Creator Yan
  */
 public void SetUpPortal(int sceneNum)
 {
     //Debug.Log ("setting up portal");
     if (portalPanel == null)
     {
         return;
     }
     Button[] b = portalPanel.GetComponentsInChildren <Button> ();
     foreach (var item in b)
     {
         item.interactable = AllEventList.returnStatus(item.name, sceneNum);
     }
 }
Example #4
0
    /* initialize everything
     * creator:Yan Zhang, myles
     */
    void Start()
    {
        //set count to 0
        enemycount = 0;
        //get the current scene num
        sceneNum = SceneManager.GetActiveScene().buildIndex;
        //Load all the quest object in the scene
        GlobalControl.Instance.FindQuestObjectLoad(sceneNum);
        //set the portal interface for this scene
        SetUpPortal(sceneNum);
        //if it is village scene now
        //if the tutorial does happened put player in the beginnign of the village
        // if the tutorial happend enable all the npcs and disable all the screaming audio and fire in the scene
        if (sceneNum == 0)
        {
            //Debug.Log ("in village");
            if (!AllEventList.returnStatus("villageInitial", 0))
            {
                Player.instance.GetComponent <NavMeshAgent> ().enabled = false;
                Player.instance.transform.position = new Vector3(52.27f, 0.203f, 192.47f);
                Player.instance.GetComponent <NavMeshAgent> ().enabled = true;

                //Disable AI pathing
                GameObject.Find("Villager Paths").SetActive(false);
                GameObject.Find("Horse Paths").SetActive(false);

                //Music
                GameObject.Find("Village (Calm) Music").SetActive(false);
            }
            if (AllEventList.returnStatus("villageInitial", 0))
            {
                GameObject.FindWithTag("ScreamingVillagers").SetActive(false);
                GameObject.FindWithTag("Fire").SetActive(false);
                GameObject.FindWithTag("Villager").SetActive(false);
                villageElder.SetActive(true);
                witch.SetActive(true);

                //Music
                GameObject.Find("Village (Attack) Music").SetActive(false);

                initialText.SetActive(false);
            }
            // if a quest is complete need to set grand father enable
            if (AllConditions.returnCondition("Get the eternal flame"))
            {
                grandFather.SetActive(true);
            }
        }
    }
Example #5
0
    private static void CreateAllEventListAsset()
    {
        if (AllEventList.Instance)
        {
            return;
        }

        AllEventList instance = CreateInstance <AllEventList>();

        AssetDatabase.CreateAsset(instance, creationPath);

        AllEventList.Instance = instance;

        instance.eventList = new List <QuestEvent>();
    }
Example #6
0
 /*increase count on the village scene enemy to detect weather the initial event is finished or not
  * Creator: Yan
  */
 public void increaseCount()
 {
     //event complete when enemy count is 9
     if (enemycount == 9)
     {
         AllEventList.changeStatus("villageInitial", 0, true);
         GameObject.FindWithTag("Villager").SetActive(false);
         GameObject.FindWithTag("ScreamingVillagers").SetActive(false);
         GameObject.FindWithTag("Fire").SetActive(false);
         villageElder.SetActive(true);
         witch.SetActive(true);
         initialText.SetActive(false);
     }
     else
     {
         enemycount += 1;
         //Debug.Log(enemycount);
     }
 }
    /*
     * Trigger death of enemy. Drops loot and destorys game object
     * Creator: Myles Hangen
     */
    public virtual void Die()
    {
        //Debug.Log("die in enemy");
        //for village scene initial event
        int scenenum = SceneManager.GetActiveScene().buildIndex;

        if (scenenum == 0 && AllEventList.returnStatus("villageInitial", 0) == false)
        {
            Debug.Log("Increasing count.");
            ManageScene.instance.increaseCount();
        }
        //
        if (aiGroundSwarm.instance != null)
        {
            aiGroundSwarm.instance.deathCounter++;
        }
        isDead = true;
        if (con != null)
        {
            con.enabled = false;
        }
        agent.enabled = false;
        col.enabled   = false;
        if (table != null)
        {
            table.DropItem();
        }

        //Play a randomization of clips in list if muiltple exist
        if (enemyDeathClips.Length > 0)
        {
            int x = (int)Random.Range(0.0f, enemyDeathClips.Length);
            AudioSource.PlayClipAtPoint(enemyDeathClips[x], transform.position, 1.0f);
        }

        TimeOfDeath();
        Destroy(gameObject, 10f);
    }
    public void SaveData()
    {
        if (!AllEventList.returnStatus("villageInitial", 0))
        {
            Debug.Log("CANNOT SAVE DURING TUTORIAL!");
            return;
        }
        Debug.Log("Saving Data...");
        PlayerState.Instance.localPlayerData.SceneID     = SceneManager.GetActiveScene().buildIndex;
        PlayerState.Instance.localPlayerData.PositionX   = Player.instance.transform.position.x;
        PlayerState.Instance.localPlayerData.PositionY   = Player.instance.transform.position.y;
        PlayerState.Instance.localPlayerData.PositionZ   = Player.instance.transform.position.z;
        PlayerState.Instance.localPlayerData.HP          = Player.instance.playerStats.currentHealth;
        PlayerState.Instance.localPlayerData.camPosX     = cam.transform.position.x;
        PlayerState.Instance.localPlayerData.camPosY     = cam.transform.position.y;
        PlayerState.Instance.localPlayerData.camPosZ     = cam.transform.position.z;
        PlayerState.Instance.localPlayerData.currentXP   = Player.instance.playerStats.currentExperience;
        PlayerState.Instance.localPlayerData.level       = Player.instance.playerStats.level;
        PlayerState.Instance.localPlayerData.currentgold = Player.instance.playerStats.gold;
        //PlayerState.Instance.localPlayerData.currentgold = Convert.ToInt32(Inventory.instance.gold.GetComponents<Text>());
        Inventory.instance.OnBeforeSerialize();
        EquipmentManager.instance.OnBeforeSerialize();
        PlayerState.Instance.localPlayerData.itemIDs.Clear();

        foreach (int i in Inventory.instance.itemIDs)
        {
            PlayerState.Instance.localPlayerData.itemIDs.Add(i);
        }
        //EquipmentManager.instance.CheckEquipmentID();
        for (int i = 0; i < EquipmentManager.instance.equipmentIDs.Length; i++)
        {
            if (EquipmentManager.instance.equipmentIDs[i] == 0)
            {
                PlayerState.Instance.localPlayerData.equipmentIDs[i] = 0;
                continue;
            }
            PlayerState.Instance.localPlayerData.equipmentIDs[i] = EquipmentManager.instance.equipmentIDs[i];
        }
        for (int i = 0; i < EquipmentManager.instance.SkillDash_IDs.Length; i++)
        {
            if (EquipmentManager.instance.SkillDash_IDs[i] == 0)
            {
                PlayerState.Instance.localPlayerData.SkillDash_IDs[i] = 0;
                continue;
            }
            PlayerState.Instance.localPlayerData.SkillDash_IDs[i] = EquipmentManager.instance.SkillDash_IDs[i];
        }

        for (int i = 0; i < EquipmentManager.instance.SkillAOE_IDs.Length; i++)
        {
            if (EquipmentManager.instance.SkillAOE_IDs[i] == 0)
            {
                PlayerState.Instance.localPlayerData.SkillAOE_IDs[i] = 0;
                continue;
            }
            PlayerState.Instance.localPlayerData.SkillAOE_IDs[i] = EquipmentManager.instance.SkillAOE_IDs[i];
        }

        for (int i = 0; i < EquipmentManager.instance.SkillProjectile_IDs.Length; i++)
        {
            //Debug.Log(EquipmentManager.instance.SkillProjectile_IDs[i]);
            if (EquipmentManager.instance.SkillProjectile_IDs[i] == 0)
            {
                PlayerState.Instance.localPlayerData.SkillProjectile_IDs[i] = 0;
                continue;
            }
            PlayerState.Instance.localPlayerData.SkillProjectile_IDs[i] = EquipmentManager.instance.SkillProjectile_IDs[i];
        }
        GlobalControl.Instance.SaveData();
    }
Example #9
0
    /*
     * fill arrays with gameobjects tagged as "Enemy" and "EnemyArcher"
     * add the enemies to the enemy dictionary. if the enemies are contained
     * in the global scenedeathlists then they are set to be inactive.
     */
    void Start()
    {
        E.Clear();
        var respawns   = GameObject.FindGameObjectsWithTag("Enemy");
        var respawns2  = GameObject.FindGameObjectsWithTag("EnemyArcher");
        int numEnemies = respawns.Length + respawns2.Length;

        Debug.Log("Number of enemies: " + numEnemies);
        foreach (GameObject enemy in respawns)
        {
            // Debug.Log(enemy.name);
            if (!E.ContainsKey(enemy.name))
            {
                E.Add(enemy.name, enemy);
            }
        }
        foreach (GameObject enemy in respawns2)
        {
            if (!E.ContainsKey(enemy.name))
            {
                E.Add(enemy.name, enemy);
            }
        }


        sceneID = SceneManager.GetActiveScene().buildIndex;

        foreach (KeyValuePair <int, List <EnemyDeathTime> > deathList in GlobalControl.Instance.SceneDeathLists)
        {
            if (deathList.Key == sceneID && deathList.Value.Count > 0)
            {
                foreach (EnemyDeathTime dt in deathList.Value)
                {
                    Debug.Log("name: " + dt.name + " time of death: " + dt.deathTime);
                    if (Time.time - dt.deathTime < respawnTimer)
                    {
                        if (E.ContainsKey(dt.name))
                        {
                            GameObject enemy = E [dt.name];
                            enemy.SetActive(false);
                        }
                    }
                    else
                    {
                        enemyToRemove.Push(dt);
                    }
                }
                while (enemyToRemove.Count > 0)
                {
                    deathList.Value.Remove(enemyToRemove.Pop());
                }
            }
        }

        if (AllEventList.returnStatus("villageInitial", 0))
        {
            if (E.ContainsKey("Enemies"))
            {
                E ["Enemies"].SetActive(false);
            }
        }
    }
    /*
     * update function that saves player data when F7 is pressed and loads player data when
     * F10 is pressed.
     * Creator: Myles Hagen
     */
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.F7))
        {
            if (!AllEventList.returnStatus("villageInitial", 0))
            {
                Debug.Log("CANNOT SAVE DURING TUTORIAL!");
                return;
            }
            Debug.Log("Saving Data...");

            // save all relevant player attributes as well as scene index and camera position
            PlayerState.Instance.localPlayerData.SceneID     = SceneManager.GetActiveScene().buildIndex;
            PlayerState.Instance.localPlayerData.PositionX   = transform.position.x;
            PlayerState.Instance.localPlayerData.PositionY   = transform.position.y;
            PlayerState.Instance.localPlayerData.PositionZ   = transform.position.z;
            PlayerState.Instance.localPlayerData.HP          = Player.instance.playerStats.currentHealth;
            PlayerState.Instance.localPlayerData.currentRage = Player.instance.playerStats.currentRage;
            PlayerState.Instance.localPlayerData.camPosX     = cam.transform.position.x;
            PlayerState.Instance.localPlayerData.camPosY     = cam.transform.position.y;
            PlayerState.Instance.localPlayerData.camPosZ     = cam.transform.position.z;
            PlayerState.Instance.localPlayerData.currentXP   = Player.instance.playerStats.currentExperience;
            PlayerState.Instance.localPlayerData.level       = Player.instance.playerStats.level;
            PlayerState.Instance.localPlayerData.currentgold = Player.instance.playerStats.gold;
            Inventory.instance.OnBeforeSerialize();
            EquipmentManager.instance.OnBeforeSerialize();
            PlayerState.Instance.localPlayerData.itemIDs.Clear();

            // store inventory item ids
            foreach (int i in Inventory.instance.itemIDs)
            {
                PlayerState.Instance.localPlayerData.itemIDs.Add(i);
            }

            // store equipment item ids
            for (int i = 0; i < EquipmentManager.instance.equipmentIDs.Length; i++)
            {
                if (EquipmentManager.instance.equipmentIDs[i] == 0)
                {
                    PlayerState.Instance.localPlayerData.equipmentIDs[i] = 0;
                    continue;
                }
                PlayerState.Instance.localPlayerData.equipmentIDs[i] = EquipmentManager.instance.equipmentIDs[i];
            }

            // store potion ids
            for (int i = 0; i < EquipmentManager.instance.Potion_IDs.Length; i++)
            {
                if (EquipmentManager.instance.Potion_IDs[i] == 0)
                {
                    PlayerState.Instance.localPlayerData.Potions_IDs[i] = 0;
                    continue;
                }
                PlayerState.Instance.localPlayerData.Potions_IDs[i] = EquipmentManager.instance.Potion_IDs[i];
            }

            // store dash skill gem ids
            for (int i = 0; i < EquipmentManager.instance.SkillDash_IDs.Length; i++)
            {
                if (EquipmentManager.instance.SkillDash_IDs[i] == 0)
                {
                    PlayerState.Instance.localPlayerData.SkillDash_IDs[i] = 0;
                    continue;
                }
                PlayerState.Instance.localPlayerData.SkillDash_IDs[i] = EquipmentManager.instance.SkillDash_IDs[i];
            }

            // store aoe skill gem ids
            for (int i = 0; i < EquipmentManager.instance.SkillAOE_IDs.Length; i++)
            {
                if (EquipmentManager.instance.SkillAOE_IDs[i] == 0)
                {
                    PlayerState.Instance.localPlayerData.SkillAOE_IDs[i] = 0;
                    continue;
                }
                PlayerState.Instance.localPlayerData.SkillAOE_IDs[i] = EquipmentManager.instance.SkillAOE_IDs[i];
            }

            // store projectile skill ids
            for (int i = 0; i < EquipmentManager.instance.SkillProjectile_IDs.Length; i++)
            {
                if (EquipmentManager.instance.SkillProjectile_IDs[i] == 0)
                {
                    PlayerState.Instance.localPlayerData.SkillProjectile_IDs[i] = 0;
                    continue;
                }
                PlayerState.Instance.localPlayerData.SkillProjectile_IDs[i] = EquipmentManager.instance.SkillProjectile_IDs[i];
            }

            GlobalControl.Instance.SaveData(); // save data to disk
        }

        // load data from disk and load scene
        if (Input.GetKeyDown(KeyCode.F10))
        {
            Debug.Log("Loading Data...");
            GlobalControl.Instance.LoadData();
            GlobalControl.Instance.IsSceneBeingLoaded = true;

            int whichScene = GlobalControl.Instance.LocalCopyOfData.SceneID;
            GlobalControl.Instance.newSceneID = whichScene;
            SceneManager.LoadSceneAsync(9, LoadSceneMode.Single);
        }
    }