コード例 #1
0
        public ActionButtonTrain(RegisteredObject obj) : base(string.Empty)
        {
            this.entityData = obj.getPrefab().GetComponent <UnitBase>().getData();
            this.buttonText = this.entityData.getUnitTypeName() + " (" + this.entityData.cost + ")";

            this.setMainActionFunction((unit) => {
                BuildingTrainingHouse trainingHouse = (BuildingTrainingHouse)unit;
                if (trainingHouse.tryAddToQueue(obj))
                {
                    // Remove resources
                    trainingHouse.getTeam().reduceResources(this.entityData.cost);
                }
            });

            this.setShouldDisableFunction((entity) => {
                return(this.entityData.cost > entity.getTeam().getResources());
            });
        }
コード例 #2
0
        public UnitStats(EntityBaseStats baseStats) : this()
        {
            this.baseStats = baseStats;

            int easterEggRnd = Random.Range(0, 100000);

            if (easterEggRnd == 111599)
            {
                this.firstName      = "PJ";
                this.lastName       = "Didelot";
                this.gender         = EnumGender.MALE;
                this.characteristic = Characteristic.a; // TODO Set to the right thing.
            }
            else
            {
                Names.getRandomName(this.gender, out this.firstName, out this.lastName);
                this.gender         = Random.Range(0, 1) == 0 ? EnumGender.MALE : EnumGender.FEMALE;
                this.characteristic = Characteristic.ALL[Random.Range(0, Characteristic.ALL.Length)];
            }
        }
コード例 #3
0
        public UnitStats(NbtCompound tag, EntityBaseStats baseStats) : this()
        {
            this.baseStats = baseStats;

            NbtCompound tag1 = tag.getCompound("stats");

            this.firstName      = tag1.getString("firstName");
            this.lastName       = tag1.getString("lastName");
            this.gender         = tag1.getByte("gender") == 1 ? EnumGender.MALE : EnumGender.FEMALE;
            this.characteristic = Characteristic.ALL[tag1.getInt("characteristicID")];

            this.distanceWalked.readFromNbt(tag1);
            this.timeAlive.readFromNbt(tag1);
            this.unitsKilled.readFromNbt(tag1);
            this.buildingsDestroyed.readFromNbt(tag1);
            this.damageDelt.readFromNbt(tag1);
            this.damageTaken.readFromNbt(tag1);
            this.resourcesCollected.readFromNbt(tag1);
            this.buildingsBuilt.readFromNbt(tag1);
            this.repairsDone.readFromNbt(tag1);
        }