コード例 #1
0
ファイル: PumpkinClass.cs プロジェクト: BroodLord/TeamProject
 public override void UpdatePlant(int DayAmount)
 {
     if (mHarvestable != true)
     {
         if (Dictioary == null)
         {
             Dictioary = GameObject.FindGameObjectWithTag("TileMapManager").GetComponent <TileDictionaryClass>();
         }
         PlantAbstractClass P = Dictioary.TileMapData.ElementAt(0).Value[ID].GetPlant();
         P.mGrowth = true;
         if (!P.mWatered)
         {
             DestoryPlant();
         }
         else
         {
             Dictioary.TileMapData.ElementAt(0).Value[ID].SetWatered(false);
         }
         CurrentDays += DayAmount;
         if (CurrentDays >= 0 && CurrentDays < 1)
         {
             mSpriteIndex = 0;
         }
         if (CurrentDays >= 4 && CurrentDays < 8)
         {
             mSpriteIndex = 1;
         }
         if (CurrentDays >= 8)
         {
             mSpriteIndex = 2;
             mHarvestable = true;
         }
     }
 }
コード例 #2
0
ファイル: DOLDatabase.cs プロジェクト: BroodLord/TeamProject
    public void DestoryObjects()
    {
        GameObject          Manager    = GameObject.FindGameObjectWithTag("InventoryManager");
        InventoryClass      Invent     = Manager.GetComponent <InventoryClass>();
        HotBarClass         HotBar     = Manager.GetComponent <HotBarClass>();
        TileDictionaryClass Dictionary = GameObject.FindGameObjectWithTag("TileMapManager").GetComponent <TileDictionaryClass>();

        // Loops through all the databases and makes the clones are don't destory on load
        foreach (var BaseV in Dictionary.TileMapData)
        {
            foreach (var ChildV in BaseV.Value)
            {
                Destroy(ChildV.Value.Clone);
            }
        }

        for (int i = 0; i < Invent.ItemList.Length; i++)
        {
            Destroy(Invent.ItemList[i]);
        }
        for (int i = 0; i < HotBar.ItemList.Length; i++)
        {
            Destroy(HotBar.ItemList[i]);
        }

        for (int i = 0; i < DOLList.Count; i++)
        {
            Destroy(DOLList[i]);
        }
        DOLList.Clear();
    }
コード例 #3
0
 public override void useTool()
 {
     // Only use the tool if we are on any of the mines levels
     if (SceneManager.GetActiveScene().name == "Forest")
     {
         Dictioary = GameObject.FindGameObjectWithTag("TileMapManager").GetComponent <TileDictionaryClass>();
         //rockPlacer = GameObject.FindGameObjectWithTag("Rockplacer").GetComponent<JunkPlacer>();
         cInventory = GameObject.FindGameObjectWithTag("InventoryManager").GetComponent <InventoryClass>();
         //TODO - when we add more grids and tilemaps, this will break
         // Get the camera position to world.
         Vector3    pos    = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         Vector3Int posInt = grid.WorldToCell(pos);
         // check if the dictionary has an ore at the given location
         if (Dictioary.TileMapData.ElementAt(4).Value[posInt].HasItem())
         {
             ItemBase    Item  = Dictioary.TileMapData.ElementAt(4).Value[posInt].GetItem();
             AudioSource Audio = gameObject.GetComponentInParent <AudioSource>();
             /*Play the sound*/
             Audio.clip = GetSoundEffect();
             Audio.Play();
             Debug.Log("GATHERED WOOD");
             ToolUsed = true;
             /****************/
             // Assess the ore
             InventoryAssessment(GetTreeItem(Item), posInt);
             // Edit the dictionary
             Dictioary.TileMapData.ElementAt(4).Value[posInt].TileMap.SetTile(posInt, GetTile());
             Dictioary.TileMapData.ElementAt(4).Value.Remove(posInt);
         }
     }
 }
コード例 #4
0
ファイル: PlantSeed.cs プロジェクト: BroodLord/TeamProject
    public override void useTool()
    {
        // Set the plant prefab to be the base one
        PlantPrefab = bPrefab;
        Dictioary   = GameObject.FindGameObjectWithTag("TileMapManager").GetComponent <TileDictionaryClass>();
        //TODO - when we add more grids and tilemaps, this will break
        // Convert mouse to world point
        pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector3Int posInt = grid.LocalToCell(pos);

        // Check that point doesn't have a plant and contains the key
        if (Dictioary.TileMapData.ElementAt(0).Value.ContainsKey(posInt) && !Dictioary.TileMapData.ElementAt(0).Value[posInt].HasPlant())
        {
            /*Subtract one as we only use 1 seed at a time, if it drops below 0 then remove the item*/
            this.SubstractAmount(1);
            HotBarClass HotBar = GameObject.FindGameObjectWithTag("InventoryManager").GetComponent <HotBarClass>();
            if (this.GetAmount() <= 0)
            {
                HotBar.RemoveItem(this.GetName());
            }
            /********************************************************************************************/
            ID = posInt;

            /*Get the audio the play it*/
            AudioSource Audio = gameObject.GetComponentInParent <AudioSource>();
            Audio.clip = GetSoundEffect();
            Audio.Play();
            /***************************/

            Debug.Log("Seed Planted");
            ToolUsed = true;
            /*Create a clone and instantiate it*/
            GameObject Clone;
            Clone = Instantiate(PlantPrefab, new Vector3(posInt.x + 0.5f, posInt.y + 0.5f, posInt.z), Quaternion.identity);
            /*****************************/
            /* Set up the plant for the clone on that spot in the database */
            PlantAbstractClass TempPlant = Clone.GetComponent <PlantAbstractClass>();
            TempPlant.ID  = ID;
            TempPlant.pos = pos;
            TempPlant.AddAmount(1);
            Dictioary.TileMapData.ElementAt(0).Value[posInt].SetPlant(TempPlant);
            Dictioary.TileMapData.ElementAt(0).Value[posInt].Clone = Clone;
            if (Dictioary.TileMapData.ElementAt(0).Value[posInt].IsWatered())
            {
                TempPlant.mWatered = true;
            }
            else
            {
                TempPlant.mWatered = false;
            }
            HotBar.UpdateUI();

            /*******************************************************************/
        }
        else
        {
            Debug.Log(tileMap.GetTile(posInt).name);
            Debug.Log("Plot already has a plant placed there");
        }
    }
コード例 #5
0
ファイル: HoeScript.cs プロジェクト: BroodLord/TeamProject
 public override void useTool()
 {
     if (SceneManager.GetActiveScene().name == "Farmland")
     {
         Dictioary = GameObject.FindGameObjectWithTag("TileMapManager").GetComponent <TileDictionaryClass>();
         //TODO - when we add more grids and tilemaps, this will break
         // Get the mouse positon in world
         Vector3    pos    = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         Vector3Int posInt = grid.LocalToCell(pos);
         // check if the key is already on the Dictioary
         if (!Dictioary.TileMapData.ElementAt(0).Value.ContainsKey(posInt))
         {
             /*Play the sound effects*/
             AudioSource Audio = gameObject.GetComponentInParent <AudioSource>();
             Audio.clip = GetSoundEffect();
             Audio.Play();
             /***************************/
             Debug.Log("This is hoeing");
             ToolUsed = true;
             /* Added the edited tile to the Dictioary*/
             TileDataClass Temp = new TileDataClass();
             Dictioary.TileMapData.ElementAt(0).Value.Add(posInt, Temp);
             Dictioary.TileMapData.ElementAt(0).Value[posInt].TileMap.SetTile(posInt, GetTile());
             Dictioary.TileMapData.ElementAt(0).Value[posInt].Tile = tileMap.GetTile(posInt);
             /********************************************************/
         }
         else
         {
             Debug.Log(tileMap.GetTile(posInt).name);
             Debug.Log("This is already hoed");
         }
     }
 }
コード例 #6
0
ファイル: PumpkinClass.cs プロジェクト: BroodLord/TeamProject
 private void Start()
 {
     Dictioary   = GameObject.FindGameObjectWithTag("TileMapManager").GetComponent <TileDictionaryClass>();
     mItemType   = ItemTypes.Seed;
     CurrentDays = mCurrentDays;
     GrowthTime  = mGrowthTime;
     Watered     = mWatered;
 }
コード例 #7
0
ファイル: LoadLevel.cs プロジェクト: BroodLord/TeamProject
    public void TransferLevel(string LevelName, Vector3 startLoc)
    {
        Loading = true;
        DOLDatabase DOLD = GameObject.FindGameObjectWithTag("LoadManager").GetComponent <DOLDatabase>();

        if (SceneManager.GetActiveScene().name != "LoadSaveScene" && SceneManager.GetActiveScene().name != "InitScene")
        {
            Transition = GameObject.FindGameObjectWithTag("Transition").GetComponent <Animator>();
            DontDestroyOnLoad(GameObject.FindGameObjectWithTag("EventSystem"));
            DOLD.Add(GameObject.FindGameObjectWithTag("EventSystem"));
        }

        Dictionary = GameObject.FindGameObjectWithTag("TileMapManager").GetComponent <TileDictionaryClass>();
        Player     = GameObject.FindGameObjectWithTag("Player");
        UICanvas   = GameObject.FindGameObjectWithTag("Canvas");
        GameObject     Manager = GameObject.FindGameObjectWithTag("InventoryManager");
        InventoryClass Invent  = Manager.GetComponent <InventoryClass>();
        HotBarClass    HotBar  = Manager.GetComponent <HotBarClass>();

        // Dont destory on load the Dictionary because we need it
        DontDestroyOnLoad(Dictionary);
        DOLD.Add(Dictionary.gameObject);
        if (LevelName != "Farmland")
        {
            // Loops through all the databases and makes the clones are don't destory on load
            foreach (var BaseV in Dictionary.TileMapData)
            {
                foreach (var ChildV in BaseV.Value)
                {
                    if (ChildV.Value.Clone != null)
                    {
                        DontDestroyOnLoad(ChildV.Value.Clone);
                    }
                }
            }
        }
        // Set up the new start location
        StartLocation = new Vector3(startLoc.x, startLoc.y, startLoc.z);
        // Loop through the hot bar and inventory and don't destory on load everything
        for (int i = 0; i < Invent.ItemList.Length; i++)
        {
            if (Invent.ItemList[i] != null)
            {
                DontDestroyOnLoad(Invent.ItemList[i]);
            }
        }
        for (int i = 0; i < HotBar.ItemList.Length; i++)
        {
            if (HotBar.ItemList[i] != null)
            {
                DontDestroyOnLoad(HotBar.ItemList[i]);
            }
        }
        // load level with a selected level
        LoadNextLevel(LevelName);
    }
コード例 #8
0
ファイル: PumpkinClass.cs プロジェクト: BroodLord/TeamProject
    public override void UpdatePlantSprite()
    {
        if (Dictioary == null)
        {
            Dictioary = GameObject.FindGameObjectWithTag("TileMapManager").GetComponent <TileDictionaryClass>();
        }
        Seeds = GameObject.FindObjectOfType <PlantSeed>();
        PlantAbstractClass PrefabTurnip = Dictioary.TileMapData.ElementAt(0).Value[ID].GetPlant();
        SpriteRenderer     S            = Dictioary.TileMapData.ElementAt(0).Value[ID].Clone.GetComponent <SpriteRenderer>();

        S.sprite = PrefabTurnip.mGrowthSprites[PrefabTurnip.mSpriteIndex];
    }
コード例 #9
0
ファイル: CornClass.cs プロジェクト: BroodLord/TeamProject
    public override void UpdatePlantSprite()
    {
        // Get the dictioary because we will be in another scene when this happens
        if (Dictioary == null)
        {
            Dictioary = GameObject.FindGameObjectWithTag("TileMapManager").GetComponent <TileDictionaryClass>();
        }
        /* Get the plant and update the sprite for the UI */
        //Seeds = GameObject.FindObjectOfType<PlantSeed>();
        PlantAbstractClass Prefab = Dictioary.TileMapData.ElementAt(0).Value[ID].GetPlant();
        SpriteRenderer     S      = Dictioary.TileMapData.ElementAt(0).Value[ID].Clone.GetComponent <SpriteRenderer>();

        S.sprite = Prefab.mGrowthSprites[Prefab.mSpriteIndex];
    }
コード例 #10
0
 public override void useTool()
 {
     if (SceneManager.GetActiveScene().name == "Farmland")
     {
         Dictioary = GameObject.FindGameObjectWithTag("TileMapManager").GetComponent <TileDictionaryClass>();
         //TODO - when we add more grids and tilemaps, this will break
         // Get the mouse pos to world
         Vector3    pos    = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         Vector3Int posInt = grid.LocalToCell(pos);
         if (Dictioary.TileMapData.ElementAt(0).Value.ContainsKey(posInt))
         {
             // Shows the name of the tile at the specified coordinates
             // Check if it has already been watered
             if (!Dictioary.TileMapData.ElementAt(0).Value[posInt].IsWatered())
             {
                 //Debug.Log(tileMap.GetTile(posInt).name);
                 /*Play the sound effect*/
                 AudioSource Audio = gameObject.GetComponentInParent <AudioSource>();
                 Audio.clip = GetSoundEffect();
                 Audio.Play();
                 /*************************/
                 Debug.Log("This is watered");
                 ToolUsed = true;
                 /*Edit the tile so it is watered*/
                 Dictioary.TileMapData.ElementAt(0).Value[posInt].TileMap.SetTile(posInt, GetTile());
                 Dictioary.TileMapData.ElementAt(0).Value[posInt].Tile = tileMap.GetTile(posInt);
                 Dictioary.TileMapData.ElementAt(0).Value[posInt].SetWatered(true);
                 PlantAbstractClass P = Dictioary.TileMapData.ElementAt(0).Value[posInt].GetPlant();
             }
             else
             {
                 Debug.Log("This is already watered");
             }
         }
         else
         {
             Debug.Log(tileMap.GetTile(posInt).name);
             Debug.Log("Needs to be Hoed first");
         }
     }
 }
コード例 #11
0
ファイル: CornClass.cs プロジェクト: BroodLord/TeamProject
 // Used to update the plant
 public override void UpdatePlant(int DayAmount)
 {
     // Only update if the plant isn't full grown.
     if (mHarvestable != true)
     {
         // Get the dictioary because we will be in another scene when this happens
         if (Dictioary == null)
         {
             Dictioary = GameObject.FindGameObjectWithTag("TileMapManager").GetComponent <TileDictionaryClass>();
         }
         // Gets the current plant
         PlantAbstractClass P = Dictioary.TileMapData.ElementAt(0).Value[ID].GetPlant();
         P.mGrowth = true;
         // If its not watered then destory the plant else set tile watered variable to false
         if (!P.mWatered)
         {
             DestoryPlant();
         }
         else
         {
             Dictioary.TileMapData.ElementAt(0).Value[ID].SetWatered(false);
         }
         /*Update the sprite if a number of days have passed*/
         CurrentDays += DayAmount;
         if (CurrentDays >= 0 && CurrentDays < 1)
         {
             mSpriteIndex = 0;
         }
         if (CurrentDays >= 3 && CurrentDays < 6)
         {
             mSpriteIndex = 1;
         }
         if (CurrentDays >= 6)
         {
             mSpriteIndex = 2;
             mHarvestable = true;
         }
     }
 }
コード例 #12
0
 public override void useTool()
 {
     if (SceneManager.GetActiveScene().name == "Farmland")
     {
         Dictioary = GameObject.FindGameObjectWithTag("TileMapManager").GetComponent <TileDictionaryClass>();
         //TODO - when we add more grids and tilemaps, this will break
         // Get the mouse positon in world
         Vector3    pos    = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         Vector3Int posInt = grid.LocalToCell(pos);
         // Check if the dictionary has a plant there
         if (Dictioary.TileMapData.ElementAt(0).Value[posInt].HasPlant())
         {
             // check if that plant is harvestable
             PlantAbstractClass Plant = Dictioary.TileMapData.ElementAt(0).Value[posInt].GetPlant();
             if (Plant.mHarvestable)
             {
                 cInventory = GameObject.FindGameObjectWithTag("InventoryManager").GetComponent <InventoryClass>();
                 // Play the sound effect
                 AudioSource Audio = gameObject.GetComponentInParent <AudioSource>();
                 Audio.clip = GetSoundEffect();
                 Audio.Play();
                 ToolUsed = true;
                 /************************/
                 //Debug.Log("GATHERED PLANT");
                 // Asset the plant and destory the planted one.
                 InventoryAssessment(GetPlantItem(Plant.XMLName), posInt);
                 Plant.DestoryPlant();
             }
         }
         else
         {
             Debug.Log(tileMap.GetTile(posInt).name);
             Debug.Log("No Plant to Gather");
         }
     }
 }
コード例 #13
0
    IEnumerator Start()
    {
        // Wait for a set time so the game can register what we have loaded into the level
        yield return(new WaitForSeconds(0.1f));

        // Find all the components need.
        Dictioary = GameObject.FindGameObjectWithTag("TileMapManager").GetComponent <TileDictionaryClass>();
        XML       = GameObject.FindGameObjectWithTag("ItemManager").GetComponent <XMLParser>();
        cClock    = GameObject.FindGameObjectWithTag("Canvas").GetComponent <Clock>();
        //DataBase = new Dictionary<Vector3Int, ItemBase>();
        // If the level is the same as the one we want to check and the reset hasn't been done
        if (SceneManager.GetActiveScene().name == "Forest" && cClock.WeeklyReset[3])
        {
            cClock.WeeklyReset[3] = false;
            PlaceTrees();
        }
        else if (SceneManager.GetActiveScene().name == "Forest")
        {
            foreach (var Childv in Dictioary.TileMapData.ElementAt(4).Value)
            {
                Childv.Value.GetTileMap();
                Childv.Value.TileMap.SetTile(Childv.Key, Childv.Value.Tile);
            }
        }

        if (SceneManager.GetActiveScene().name == "Mines" && cClock.WeeklyReset[0])
        {
            // Reset the reset to false so it doesn't do it again
            cClock.WeeklyReset[0] = false;
            // place rocks
            PlaceRocks();
        }
        // if the level is the same and we have placed rocks before then we want to loop through all the dictionary and place the rocks
        else if (SceneManager.GetActiveScene().name == "Mines")
        {
            foreach (var Childv in Dictioary.TileMapData.ElementAt(1).Value)
            {
                Childv.Value.GetTileMap();
                Childv.Value.TileMap.SetTile(Childv.Key, Childv.Value.Tile);
            }
        }
        // Same as above
        if (SceneManager.GetActiveScene().name == "Mines1" && cClock.WeeklyReset[1])
        {
            cClock.WeeklyReset[1] = false;
            PlaceRocks();
        }
        else if (SceneManager.GetActiveScene().name == "Mines1")
        {
            foreach (var Childv in Dictioary.TileMapData.ElementAt(2).Value)
            {
                Childv.Value.GetTileMap();
                Childv.Value.TileMap.SetTile(Childv.Key, Childv.Value.Tile);
            }
        }
        // Same as above
        if (SceneManager.GetActiveScene().name == "Mines2" && cClock.WeeklyReset[2])
        {
            cClock.WeeklyReset[2] = false;
            PlaceRocks();
        }
        else if (SceneManager.GetActiveScene().name == "Mines2")
        {
            foreach (var Childv in Dictioary.TileMapData.ElementAt(3).Value)
            {
                Childv.Value.GetTileMap();
                Childv.Value.TileMap.SetTile(Childv.Key, Childv.Value.Tile);
            }
        }
    }