Ejemplo n.º 1
0
    /// <summary>
    /// Method to call when a unit or a resource is created or when a resource building
    /// adds or removes a worker.
    /// </summary>
    /// <param name="entity">Entity where their inner stats have changed.</param>
    /// <param name="packet">Package that represents an entity.</param>
    public void StatisticsChanged(IGameEntity entity, GrowthStatsPacket packet)
    {
        if (statistics[packet.type].ContainsKey(entity))
        {
            statistics[packet.type][entity] = packet;
        }
        else
        {
            statistics[packet.type].Add(entity, packet);
        }

        updateStatistics();
    }
Ejemplo n.º 2
0
    // **************************************************************

    /// <summary>
    /// Creates a new package from a given entity.
    /// </summary>
    /// <param name="entity"></param>
    /// <returns></returns>
    private GrowthStatsPacket CreatePackageFromEntity(IGameEntity entity)
    {
        GrowthStatsPacket packet = new GrowthStatsPacket();

        if (entity.info.isResource)
        {
            Resource r = (Resource)entity;

            packet = new GrowthStatsPacket(GetElementFromResource(r), Mathf.Min(r.HUD_productionRate, r.HUD_currentProductionRate),
                                           r.info.resourceAttributes.updateInterval);
        }
        if (entity.info.isUnit)
        {
            Unit unit = (Unit)entity;
            packet = new GrowthStatsPacket(WorldResources.Type.FOOD, -unit.info.unitAttributes.foodConsumption, 1f);
        }

        return(packet);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Method to call when a unit or a resource is created or when a resource building 
    /// adds or removes a worker. 
    /// </summary>
    /// <param name="entity">Entity where their inner stats have changed.</param>
    /// <param name="packet">Package that represents an entity.</param>
    public void StatisticsChanged(IGameEntity entity, GrowthStatsPacket packet)
    {

        if (statistics[packet.type].ContainsKey(entity))
        {
            statistics[packet.type][entity] = packet;
        }
        else
        {
            statistics[packet.type].Add(entity, packet);
        }

        updateStatistics();
    }