예제 #1
0
    private void Awake()
    {
        this.registeredStats = new List <RegisteredStat>();

        // General Stats:
        this.leversFlipped      = this.registerStat(new StatisticInt("Levers Flipped", "leversFlipped"), EnumStatisticCategory.GENERAL);
        this.minecartsPlaced    = this.registerStat(new StatisticInt("Minecarts Placed", "minecartsPlaced"), EnumStatisticCategory.GENERAL);
        this.minecartsDestroyed = this.registerStat(new StatisticInt("Minecarts Destroyed", "minecartsDestroyed"), EnumStatisticCategory.GENERAL);

        // Worker Stats:
        this.workersHired = this.registerStat(new StatisticInt("Workers Hired", "workersHired"), EnumStatisticCategory.WORKERS);
        this.workersFired = this.registerStat(new StatisticInt("Workers Fired", "workersFired"), EnumStatisticCategory.WORKERS);

        // Tile Stats:
        TileRegistry reg = Main.instance.tileRegistry;

        for (int i = 0; i < reg.getRegistrySize(); i++)
        {
            CellData cell = reg.getElement(i);
            if (cell != null)
            {
                this.registerStat(new StatisticInt(cell.displayName + " built", cell.name + DOT_TIMES_BUILT), EnumStatisticCategory.TILES);

                if (cell is CellDataMineable)
                {
                    this.registerStat(new StatisticInt(cell.displayName + " mined", cell.name + DOT_TIMES_MINED), EnumStatisticCategory.TILES);
                }

                if (cell.isDestroyable)
                {
                    this.registerStat(new StatisticInt(cell.displayName + " destroyed", cell.name + DOT_TIMES_DESTROYED), EnumStatisticCategory.TILES);
                }
            }
        }
    }
예제 #2
0
 private UnitStats()
 {
     this.distanceWalked     = new StatisticFloat(this, "Distance Walked", "disWalked");
     this.timeAlive          = new StatisticTime(this, "Time Alive", "timeAlive");
     this.unitsKilled        = new StatisticInt(this, "Units Killed", "uKills");
     this.buildingsDestroyed = new StatisticInt(this, "Buildings Destroyed", "buildingsDestoryed");
     this.damageDelt         = new StatisticInt(this, "Damage Delt", "damageDelt");
     this.damageTaken        = new StatisticInt(this, "Damage Taken", "damageTaken");
     this.resourcesCollected = new StatisticInt(this, "Resources Collected", "resCollected");
     this.buildingsBuilt     = new StatisticInt(this, "Buildings Built", "buildingsBuilt");
     this.repairsDone        = new StatisticInt(this, "Repairs Done", "repairsDone");
 }
예제 #3
0
    public override void onAtDestination()
    {
        this.timeMining += (Time.deltaTime * this.owner.info.personality.workSpeedMultiplyer);

        int hardness = this.owner.world.getHardness(this.stonePos);

        if (this.timeMining >= this._mineSpeeds[hardness])
        {
            // Pickup the dropped item from the stone.
            CellData data = this.owner.world.getCellState(this.stonePos).data;
            if (data is CellDataMineable)
            {
                CellDataMineable dataMineable = (CellDataMineable)data;

                this.minerData.heldItem = dataMineable.droppedItem;

                if (dataMineable.showParticles)
                {
                    // Play particle (and color it)
                    Particle particle = this.owner.world.particles.spawn(this.stonePos.center, this.owner.depth, this.mineParticlePrefab);
                    if (particle != null)
                    {
                        LayerData layerData            = this.owner.world.mapGenerator.getLayerFromDepth(this.owner.depth);
                        ParticleSystem.MainModule main = particle.ps.main;
                        main.startColor = layerData.getGroundTint(this.owner.world, this.stonePos.x, this.stonePos.y);
                    }
                }

                // Add to mined stat.
                StatisticInt stat = this.owner.world.statManager.getCellMinedStat(data);
                if (stat != null)
                {
                    stat.increase(1);
                }
            }

            // Reduce hunger and energy.
            this.owner.hunger.decrease(this._hungerCost);
            this.owner.energy.decrease(this._energyCost);

            // Remove the stone.
            this.owner.world.setCell(this.stonePos, null);
            this.owner.world.targetedSquares.stopTargeting(this.stonePos);
            this.owner.world.liftFog(this.stonePos);
            this.owner.world.tryCollapse(this.stonePos);

            // Add to global mined count
            this.owner.world.stoneExcavated++;
        }
    }
예제 #4
0
    protected override void onClick(Position pos, bool isValid)
    {
        if (isValid)
        {
            int  cost       = this.popup.getDemoCost();
            bool inCreative = CameraController.instance.inCreativeMode;
            if ((inCreative || (this.money.value >= this.popup.getDemoCost()) && this.world.plotManager.isOwned(pos)))
            {
                if (!inCreative)
                {
                    this.money.value -= cost;
                }

                Vector2 particlePos;
                if (this.destroyableEntity != null)
                {
                    particlePos = this.destroyableEntity.worldPos;
                    this.world.entities.remove(this.destroyableEntity);
                }
                else
                {
                    // Add to the destroyed stat.
                    CellData     cell = this.world.getCellState(pos).data;
                    StatisticInt stat = this.world.statManager.getCellDestroyedStat(cell);
                    if (stat != null)
                    {
                        stat.increase(1);
                    }
                    else
                    {
                        print("error");
                    }

                    particlePos = pos.center;

                    // Remove the Cell.
                    this.world.setCell(pos, null);
                    this.world.tryCollapse(pos);
                }

                this.world.particles.spawn(particlePos, pos.depth, particlePrefab);
            }
        }
    }