/// <summary>
        /// Constructor, initialize variables, register resource
        /// </summary>
        /// <param name="resourceSourceWrapper">Reference to the Unity Resource Source Wrapper</param>
        /// <param name="position">Position of the Resource</param>
        /// <param name="resourceType">Type of the Resource</param>
        /// <param name="amount">Amount of the Resource</param>
        /// <param name="isInfinite">Is the resource infinite?</param>
        public ResourceSource(ResourceSourceWrapper resourceSourceWrapper, Vector3 position, ResourceType resourceType = ResourceType.Water, int amount = 10, bool isInfinite = false)
        {
            m_Position = position;
            AstarPath p = AstarPath.active;

            m_NearestNode            = p.GetNearest(position).node;
            m_ResourceSourceData     = new ResourceSourceData(resourceType, amount, isInfinite);
            ResourceSourceWrapperRef = resourceSourceWrapper;
            PlanetDatalayer.Instance.GetManager <ResourceManager>().RegisterResourceSource(this);
        }
Beispiel #2
0
 /// <summary>
 /// Collision Event
 /// </summary>
 /// <param name="collision">The collision triggering the event.</param>
 protected override void OnCollisionExit(Collision collision)
 {
     if (m_CurrentResourceSource == null)
     {
         ResourceSourceWrapper resourceSource = collision.gameObject.GetComponent <ResourceSourceWrapper>();
         if (resourceSource == null)
         {
             OwningCreatureAI.SetAnimation("Idle");
             Done();
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// Creates the Watermap based on the water and terrain
        /// </summary>
        /// <param name="terrain">Used Terrain</param>
        /// <param name="water">Used Water</param>
        /// <returns>true on success</returns>
        public bool CreateWaterMap(Terrain terrain, Water water)
        {
            if (terrain == null)
            {
                return(false);
            }

            WaterlevelMap = new float[(int)terrain.terrainData.size.x, (int)terrain.terrainData.size.z];
            RiverbankMap  = new Dictionary <Vector3, ResourceSource>();

            WaterResourceSourceWrapper = GameObject.Find("Water").GetComponent <ResourceSourceWrapper>();

            return(UpdateWatermapForRegion(new Rect(0, 0, terrain.terrainData.size.x, terrain.terrainData.size.z), terrain, water));
        }