コード例 #1
0
ファイル: Race.cs プロジェクト: TomCR94/UnityStars
    public Race setHumanoid()
    {
        setName("Humanoid");
        setPluralName("Humanoids");

        prt                   = PRT.JoaT;
        habLow                = new Hab(15, 15, 15);
        habHigh               = new Hab(85, 85, 85);
        growthRate            = 15;
        colonistsPerResource  = 1000;
        factoryOutput         = 10;
        factoryCost           = 10;
        numFactories          = 10;
        factoriesCostLess     = false;
        mineOutput            = 10;
        mineCost              = 5;
        numMines              = 10;
        techsStartHigh        = false;
        immuneGrav            = false;
        immuneTemp            = false;
        immuneRad             = false;
        spendLeftoverPointsOn = SpendLeftoverPointsOn.SurfaceMinerals;
        researchCost          = new ResearchCost(ResearchCostLevel.Standard, ResearchCostLevel.Standard, ResearchCostLevel.Standard, ResearchCostLevel.Standard,
                                                 ResearchCostLevel.Standard, ResearchCostLevel.Standard);

        init();

        return(this);
    }
コード例 #2
0
ファイル: Race.cs プロジェクト: TomCR94/UnityStars
    /**
     * Copy constructor for initializing the race for a player
     */
    public Race(Race race, Player player)
    {
        this.name                  = race.name;
        this.pluralName            = race.pluralName;
        this.prt                   = race.prt;
        this.habLow                = race.habLow;
        this.habHigh               = race.habHigh;
        this.growthRate            = race.growthRate;
        this.colonistsPerResource  = race.colonistsPerResource;
        this.factoryOutput         = race.factoryOutput;
        this.factoryCost           = race.factoryCost;
        this.numFactories          = race.numFactories;
        this.factoriesCostLess     = race.factoriesCostLess;
        this.mineOutput            = race.mineOutput;
        this.mineCost              = race.mineCost;
        this.numMines              = race.numMines;
        this.techsStartHigh        = race.techsStartHigh;
        this.immuneGrav            = race.immuneGrav;
        this.immuneTemp            = race.immuneTemp;
        this.immuneRad             = race.immuneRad;
        this.spendLeftoverPointsOn = race.spendLeftoverPointsOn;
        this.researchCost          = new ResearchCost(race.researchCost);
        //this.player = player;

        this.init();
    }
コード例 #3
0
 public ResearchCost(ResearchCost researchCost)
 {
     this.energy        = researchCost.energy;
     this.weapons       = researchCost.weapons;
     this.propulsion    = researchCost.propulsion;
     this.construction  = researchCost.construction;
     this.electronics   = researchCost.electronics;
     this.biotechnology = researchCost.biotechnology;
 }
コード例 #4
0
        public bool CreateResearchCost(ResearchCost researchCost)
        {
            outpostwarsEntities entities = new outpostwarsEntities();

            try
            {
                // Add tew New Player into the player Collection
                entities.ResearchCosts.Add(researchCost);
                // Save changes
                return(entities.SaveChanges() == 1);
            }
            catch (DbEntityValidationException ex)
            {
                LogCriticalError(ex);
            }
            return(false);
        }
コード例 #5
0
        private bool CheckRessourcesAvailability(ResearchCost cost)
        {
            Ressources ressources = Ressources.Instance;

            if (ressources.WoodQty >= cost.Wood &&
                ressources.StoneQty >= cost.Stone &&
                ressources.IronQty >= cost.Iron &&
                ressources.FoodQty >= cost.Food &&
                ressources.GoldQty >= cost.Gold &&
                ressources.ResearchQty >= cost.Research)
            {
                ressources.WoodQty     -= (cost.Wood > 0) ? cost.Wood : 0;
                ressources.StoneQty    -= (cost.Stone > 0) ? cost.Stone : 0;
                ressources.IronQty     -= (cost.Iron > 0) ? cost.Iron : 0;
                ressources.FoodQty     -= (cost.Food > 0) ? cost.Food : 0;
                ressources.GoldQty     -= (cost.Gold > 0) ? cost.Gold : 0;
                ressources.ResearchQty -= (cost.Research > 0) ? cost.Research : 0;
                return(true);
            }
            return(false);
        }
コード例 #6
0
        public bool Buy(IResearchType research)
        {
            if (research == null)
            {
                return(false);
            }

            int researchLevel = research.GetLevel();

            if (researchLevel < 0 || researchLevel >= research.GetMaxLevel())
            {
                return(false);
            }

            ResearchCost cost = research.GetResearchCost(researchLevel + 1);

            if (cost == null)
            {
                return(false);
            }

            return(CheckRessourcesAvailability(cost));
        }
コード例 #7
0
ファイル: Race.cs プロジェクト: TomCR94/UnityStars
 public void setResearchCost(ResearchCost researchCost)
 {
     this.researchCost = researchCost;
 }