Beispiel #1
0
    private void ApplyUpgrades()
    {
        int level = Upgrades.GetLevel(this.type);

        this.stats.maxHealth    += 5 * level;
        this.stats.attackDamage += 3 * level;
    }
Beispiel #2
0
        private void GetNewCard()
        {
            int randomNumber = Rng.Next(3);

            if (randomNumber == 0)
            {
                if (!isInclusingPilots && (isInclusingUpgrades || isInclusingManeuvers))
                {
                    GetNewCard(); return;
                }
                currentRandomCard     = Pilots.GetRandomPilot();
                isShowingManeuverCard = false;
            }
            else if (randomNumber == 1)
            {
                if (!isInclusingManeuvers && (isInclusingPilots || isInclusingUpgrades))
                {
                    GetNewCard(); return;
                }
                currentRandomShip     = Ships.GetRandomShip();
                isShowingManeuverCard = true;
            }
            else
            {
                if (!isInclusingUpgrades && (isInclusingPilots || isInclusingManeuvers))
                {
                    GetNewCard(); return;
                }
                currentRandomCard     = Upgrades.GetRandomUpgrade();
                isShowingManeuverCard = false;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Initiates loading for world.
        /// </summary>
        public void InitWorld()
        {
            LoadProgress = ContentLoadingProgress.InitObjects;
            if (TS1)
            {
                WorldObjectGlobals.Init();
                ((TS1ObjectProvider)WorldObjects).Init();
                LoadProgress = ContentLoadingProgress.InitArch;

                WorldWalls.InitTS1();
                WorldFloors.InitTS1();
            }
            else
            {
                WorldObjectGlobals.Init();
                ((WorldObjectProvider)WorldObjects).Init((Device != null));
                ((WorldObjectCatalog)WorldCatalog).Init(this);
                LoadProgress = ContentLoadingProgress.InitArch;

                WorldWalls.Init();
                WorldFloors.Init();
                Upgrades.Init();
                if (Mode == ContentMode.SERVER)
                {
                    Upgrades.LoadJSONTuning();
                }
            }
            WorldRoofs.Init();
            LoadProgress = ContentLoadingProgress.Done;
        }
Beispiel #4
0
    public void SetUpgradeLevel(Upgrades u, int requestedLevel)
    {
        switch (u)
        {
        case Upgrades.HeadJumpHeight:
            headJumpHeight = requestedLevel;
            HeadJumpManager.instance.UpdateJumpHeight();
            break;

        case Upgrades.AdditionalHeads:
            additionalHeads = requestedLevel;
            HeadJumpManager.instance.UpdateMaxLives();
            break;

        case Upgrades.Balance:
            balance = requestedLevel;
            BalanceSystem.instance.UpdateStability(requestedLevel);
            break;

        case Upgrades.HorseSpeed:
            gravityEffect = requestedLevel;
            HorseManager.instance.UpdateSpeed(requestedLevel);
            GameStateManager.instance.UpdateBackgroundScroll(requestedLevel);
            break;
        }
    }
Beispiel #5
0
 public void DeleteFunction(UpgradeFunction function)
 {
     QuickLogger.Debug("Deleting Function", true);
     function.DeActivateUpdate();
     Upgrades.Remove(function);
     OnUpgradeUpdate?.Invoke(null);
 }
Beispiel #6
0
 public void SaveGame(bool upgrades, bool stats)
 {
     if (!upgrades)
     {
         SaveLoadMaster.SaveProgress(currentLevel, masterMoney);
     }
     else
     {
         Upgrades ups = this.GetComponent <Upgrades>();
         if (!stats)
         {
             SaveLoadMaster.SaveProgress(currentLevel, masterMoney, new int[3] {
                 ups.aimSpeedLVL, ups.fireSpeedLVL, ups.pullPowerLVL
             }, new bool[6] {
                 ups.Hooksize, ups.scannerUpgrade, ups.aimUpgrade, ups.BackGrab, ups.Destroyer, ups.autograb
             });
         }
         else
         {
             EndGameStats gamestats = this.GetComponent <EndGameStats>();
             SaveLoadMaster.SaveProgress(currentLevel, masterMoney, new int[3] {
                 ups.aimSpeedLVL, ups.fireSpeedLVL, ups.pullPowerLVL
             }, new bool[6] {
                 ups.Hooksize, ups.scannerUpgrade, ups.aimUpgrade, ups.BackGrab, ups.Destroyer, ups.autograb
             }, new int[] { gamestats.totalCash, gamestats.orescollected, gamestats.bombesExploded, gamestats.oresenriched, gamestats.upgradespurchased });
         }
     }
 }
Beispiel #7
0
    // Start is called before the first frame update
    void Start()
    {
        Upgrades upgrades = this.gameObject.GetComponentInParent <Upgrades>();

        levelToCost       = upgrades.levelToCost;
        itemToDescription = upgrades.itemToDescription;
        itemToFile        = upgrades.itemToFile;
        curr = upgrades.curr;

        levels       = upgrades.levels;
        levelToIndex = upgrades.levelToIndex;

        itemImage       = this.transform.Find("Item Image").gameObject.GetComponent <Image>();
        itemName        = this.transform.Find("Item Name").gameObject.GetComponent <TextMeshProUGUI>();
        itemDescription = this.transform.Find("Item Description").gameObject.GetComponent <TextMeshProUGUI>();
        itemCost        = this.transform.Find("Item Cost").gameObject.GetComponent <TextMeshProUGUI>();
        itemStatus      = this.transform.Find("Item Status").gameObject.GetComponent <TextMeshProUGUI>();
        upgradeButton   = this.transform.Find("Upgrade Button").gameObject.GetComponent <Button>();
        goldNumber      = this.transform.Find("Gold").gameObject.GetComponent <TextMeshProUGUI>();

        gold = this.gameObject.GetComponentInParent <PlayerGold>().gold;

        foreach (string item in upgrades.items)
        {
            itemToStatus.Add(item, upgrades.levels[0]);
        }

        UpdateScreen();
    }
        public bool Write(DAIIO io, bool skiplength = false)
        {
            try
            {
                if (!skiplength)
                {
                    io.WriteBits(Length, LengthBits);
                }
                Offset = io.Position;
                io.WriteInt16(Version);
                if (StatsData == null)
                {
                    StatsData = new ItemAsset();
                }
                StatsData.Write(io);
                if (Version < 8)
                {
                    io.WriteInt32(Uid);
                }
                io.WriteBoolean(IsForSale);
                io.WriteBoolean(IsNew);
                io.WriteBoolean(IsCrafted);
                io.WriteInt32(StringId);
                if (StatsInstance != null)
                {
                    StatsInstance.Write(io);
                    if (Upgrades != null)
                    {
                        Upgrades.Write(io);
                        io.WriteBoolean(SuppressClassRestriction);
                        if (Version > 6)
                        {
                            io.WriteBoolean(IsPlaceHolder);
                        }
                        if (Version > 0xA)
                        {
                            io.WriteBoolean(HasSoundActionsReference);
                            if (HasSoundActionsReference)
                            {
                                SoundActionsReference.Write(io);
                            }
                        }
                    }
                }
                if (StackSize != 0xff)
                {
                    io.WriteBits(StackSize, 0x8);
                }
                if (MaxStackSize != 0xff)
                {
                    io.WriteBits(MaxStackSize, 0x8);
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
    void Awake()
    {
        gameData = GameObject.Find("DataController").GetComponent <GameData>();

        if (gameData.equippedUpgrade == Upgrades.DoubleDollaryDoos)
        {
            doubleDollaryDoosEnabled = true;
            gameData.equippedUpgrade = Upgrades.None;
            equipped = Upgrades.DoubleDollaryDoos;
        }


        if (gameData.equippedUpgrade == Upgrades.HeadStart)
        {
            headstartEnabled         = true;
            gameData.equippedUpgrade = Upgrades.None;
            equipped = Upgrades.HeadStart;
        }


        if (gameData.equippedUpgrade == Upgrades.Revive)
        {
            reviveEnabled            = true;
            gameData.equippedUpgrade = Upgrades.None;
            equipped = Upgrades.Revive;
        }

        gameData.SaveGameDataUpgradesInventory();
    }
Beispiel #10
0
 public List <int> this[Upgrades key]
 {
     get
     {
         return(GetValue(key));
     }
 }
Beispiel #11
0
 void Start()
 {
     State                 = GameState.Menu;
     upgrades              = new Upgrades();
     Cursor.visible        = false;
     Localization.language = "English";
 }
    void Update()
    {
        bool unlocked = true;

        if (activated || (precludingUpgrade != null && precludingUpgrade.isActivated()))
        {
            unlocked = false;
        }

        else if (lockingUpgrade != null && !activated)
        {
            unlocked = lockingUpgrade.isActivated();
        }

        if (unlocked && Resources.money > Upgrades.getCost(upgradeName))
        {
            //TODO: Check enough money
            button.interactable = true;
        }
        else
        {
            //show not enough cash
            button.interactable = false;
        }
    }
Beispiel #13
0
    public void AssignStructure(Structure structure)
    {
        if (_controller)
        {
            if (_structure != null)
            {
                _controller.CountStructure(_structure.type, -1);
            }
            _controller.CountStructure(structure.type, 1);
        }

        _structure = structure;
        if (currentStructure)
        {
            DestroyImmediate(currentStructure);
            currentStructure = null;
        }

        if (_structure.prefab)
        {
            currentStructure      = Instantiate(_structure.prefab, transform, false);
            currentStructure.name = $"{structure.name}";
            currentStructure.transform.GetChild(0).Rotate(Vector3.up, Random.Range(0, 360));
        }

        _upgrades = _structure.copyBuildingUpgrades();
    }
    private BlockDifficulty DeterminePowerUpBlock(Upgrades _upgradeType)
    {
        BlockDifficulty blockDifficulty = BlockDifficulty.None;

        switch (_upgradeType)
        {
        case Upgrades.ChargeUpgrade:
            blockDifficulty = BlockDifficulty.Charge;
            break;

        case Upgrades.ShieldUpgrade:
            blockDifficulty = BlockDifficulty.Shield;
            break;

        case Upgrades.MegaCoinUpgrade:
            blockDifficulty = BlockDifficulty.MegaCoin;
            break;

        default:
            blockDifficulty = BlockDifficulty.Shield;
            break;
        }

        return(blockDifficulty);
    }
Beispiel #15
0
 public void TryBuyUpgrade(Upgrades upgrade, int shopIndex)
 {
     // If player has enough money
     if (GetCurrentStatInfo(upgrade.Stat) < upgrade.ItemCap && customer.TrySpendGold(upgrade.Price)) // If the player has money and the cap is not reached
     {
         customer.BoughtItem(upgrade.Stat);
         // Updating Item description
         if (GetCurrentStatInfo(upgrade.Stat) < upgrade.ItemCap)
         {
             UpdateItemPrice(upgrade);
             buttons[shopIndex].Find("priceText").GetComponent <TextMeshProUGUI>().SetText(upgrade.Price.ToString());
             buttons[shopIndex].Find("currentStats").GetComponent <TextMeshProUGUI>().SetText($"{upgrade.UpgradeDescription} {GetCurrentStatInfo(upgrade.Stat)}/{upgrade.ItemCap}");
         }
         else
         {
             buttons[shopIndex].Find("currentStats").GetComponent <TextMeshProUGUI>().SetText("Maximum limit reaced");
             buttons[shopIndex].Find("background").GetComponent <Image>().color = Color.red;
         }
     }
     else
     {
         if (GetCurrentStatInfo(upgrade.Stat) < upgrade.ItemCap)
         {
             buttons[shopIndex].Find("currentStats").GetComponent <TextMeshProUGUI>().SetText("Insufficient funds");
             buttons[shopIndex].Find("background").GetComponent <Image>().color = Color.red;
         }
     }
 }
Beispiel #16
0
    /// <summary>
    /// every tick the player gets rewarded with a set amount of points
    /// depending on the quantity of fish and the types of fish
    /// The rewards is then multiplied with an upgradable multiplier that
    /// rewards extra points
    /// the tick is called in boidsmanager
    /// </summary>
    public static void Tick()
    {
        if (Time.time >= tickTS + tickInterval)
        {
            float sum = 0;
            sum += BoidsManager.ChromisCount *
                   (fishPassivePoints[FISH.CHROMIE] *
                    Upgrades.GetUpgradeModifier(FISH.CHROMIE));

            sum += BoidsManager.EelCount *
                   (fishPassivePoints[FISH.EEL] *
                    Upgrades.GetUpgradeModifier(FISH.EEL));

            sum += BoidsManager.MolaCount *
                   (fishPassivePoints[FISH.MOLA] *
                    Upgrades.GetUpgradeModifier(FISH.MOLA));

            Score += sum;

            lastSum = sum;

            tickTS = Time.time;

            onScoreTick?.Invoke();
        }
    }
Beispiel #17
0
    public void HasChanged()
    {
        GameObject    hovered = Hoverable.current.hoverObject;
        UpgradeButton upgrade = hovered.GetComponent <UpgradeButton>();
        Item          item    = hovered.GetComponent <Item>();

        if (upgrade != null)
        {
            string upgradeName = upgrade.upgradeName;
            print(upgradeName);
            title.text       = Upgrades.getTitle(upgradeName);
            cost.text        = "$" + Upgrades.getCost(upgradeName).ToString();
            pawnPrice.text   = "";
            description.text = Upgrades.getDescription(upgradeName);
            image.sprite     = upgrade.GetSprite();
        }
        else if (item != null)
        {
            string itemName = item.getItemName();
            print(itemName);
            title.text       = itemName;
            cost.text        = "$" + ItemInfo.itemStats[itemName]["sellPrice"].ToString();
            pawnPrice.text   = "Pawn: $" + ItemInfo.itemStats[itemName]["pawnPrice"].ToString();
            description.text = ItemInfo.itemDescription[itemName];
            image.sprite     = item.GetSprite();
        }
    }
Beispiel #18
0
    public Resources TickTile(TileGridController controller, CubeCoord pos, Upgrades upgrades, TileScript tile)
    {
        var buildingResources = upgrades.Calculate(new Resources());
        var modified          = globalUpgrades.Calculate(buildingResources);

        if (tile.Structure.type == StructureType.LUMBERJACK)
        {
            var neighborTiles = controller.GetNeighborTiles(pos);
            modified.Mul(ItemType.WOOD, neighborTiles.Count(t => t.GetComponent <TileScript>().Structure.type == StructureType.WOODS));
        }

        if (tile.Structure.type == StructureType.CHARCOAL_BURNER)
        {
            var neighborTiles = controller.GetNeighborTiles(pos);
            var cnt           = neighborTiles.Count(t => t.GetComponent <TileScript>().Structure.type == StructureType.CHARCOAL_BURNER) + 1;
            modified.Mul(ItemType.CHARCOAL, cnt);
        }

        if (modified.Items.Count > 0)
        {
            if (Global.Resources.Add(modified))
            {
                var floaty = tile.floaty(controller.worldUi.transform, modified, true, "");
                floaty.transform.position = Camera.main.WorldToScreenPoint(tile.transform.position);
            }
        }

        return(modified);
    }
    public GameObject SpawnWord(string word)
    {
        float x;

        if (Upgrades.hasUpgrade("wordGrid"))
        {
            if (gridPosLeft)
            {
                x = leftAnchor.position.x;
            }
            else
            {
                x = rightAnchor.position.x;
            }
            gridPosLeft = !gridPosLeft;
        }
        else
        {
            x = Random.Range(leftAnchor.position.x, rightAnchor.position.x);
        }
        this.transform.position = new Vector3(x, transform.position.y);
        GameObject w;

        w = Instantiate(wordObject, this.transform.position, Quaternion.identity, transform.parent);
        if (Upgrades.hasUpgrade("rigidWords"))
        {
            w.GetComponent <Rigidbody2D>().freezeRotation = true;
        }
        w.GetComponent <Word>().SetWord(word);

        return(w);
    }
Beispiel #20
0
    /// <summary>
    /// Setup the menu
    /// </summary>
    void Start()
    {
        //Add listeners
        Messenger.AddListener("setBlack", setBlack);


        smallFont.fontSize = 25;
        largeFont.fontSize = 40;

        //White font will stick out on our black background
        smallFont.normal.textColor = Color.white;
        largeFont.normal.textColor = Color.white;

        startY = -Screen.height / 2 + 120;

        //initialize GameObject_upgrades and Upgrades_upgrades
        GameObject_upgrades = GameObject.Find("Upgrades-Score");

        //Initialize fortHealth
        fort = GameObject.Find("Fort");          //get the fort
        FortHealth_fortHealth = fort.GetComponent <FortHealth>();

        //if we have now upgrades object load the prefab for upgrades onto the scene
        if (GameObject_upgrades == null)
        {
            Debug.LogWarning("Warning: Upgrades GameObject could not be found");
            GameObject_upgrades = Instantiate(Resources.Load("Upgrades-Score")) as GameObject;
        }

        Upgrades_upgrades = GameObject_upgrades.GetComponent <Upgrades>();

        //no matter what we have the upgrades object so we're good to load everything
        guiReady = true;
    }
Beispiel #21
0
        internal Player(long UserId)
        {
            this.UserId = UserId;

            this.Facebook   = new Structure.API.Facebook(this);
            this.Google     = new Structure.API.Google(this);
            this.Gamecenter = new Structure.API.Gamecenter(this);
            this.Inbox      = new Inbox(this);

            this.Castle_Resources = new Resources(this, false);
            this.Resources        = new Resources(this, true);
            this.Resources_Cap    = new Resources(this, false);
            this.Npcs             = new Npcs();
            this.Variables        = new Structure.Slots.Variables(this, true);
            this.Modes            = new Modes(this, true);

            this.Units         = new Units(this);
            this.Units2        = new Units(this);
            this.Spells        = new Units(this);
            this.Castle_Units  = new Castle_Units(this);
            this.Castle_Spells = new Castle_Units(this);

            this.Unit_Upgrades   = new Upgrades(this);
            this.Spell_Upgrades  = new Upgrades(this);
            this.Heroes_Upgrades = new Upgrades(this);

            this.Heroes_Health = new Slots();
            this.Heroes_Modes  = new Slots();
            this.Heroes_States = new Slots();
        }
Beispiel #22
0
    private IEnumerator SphereSpawn()
    {
        while (true)
        {
            int time_for_spawn = Random.Range(minTimeSpawn, maxTimeSpawn + 1);
            int random         = Random.Range(1, 4);
            yield return(new WaitForSeconds(time_for_spawn));

            Upgrades upgrade = (Upgrades)random;
            switch (upgrade)
            {
            case Upgrades.forceUpgrade:
            {
                upgradeObj = Pooling.Instance.SpawnFromPool("forceUpgrade", new Vector3(Random.Range(-9.5f, 9.5f), 14));
            }
            break;

            case Upgrades.widthUpgrade:
            {
                upgradeObj = Pooling.Instance.SpawnFromPool("widthUpgrade", new Vector3(Random.Range(-9.5f, 9.5f), 14));
            }
            break;

            case Upgrades.stickUpgrade:
            {
                upgradeObj = Pooling.Instance.SpawnFromPool("stickUpgrade", new Vector3(Random.Range(-9.5f, 9.5f), 14));
            }
            break;
            }
            upgradeObj.GetComponent <Rigidbody>().velocity = new Vector3(0, -10, 0);
        }
    }
Beispiel #23
0
        public Unit(Unit copy)
        {
            if (copy != null)
            {
                Name             = copy.Name;
                Faction          = copy.Faction;
                Keywords         = copy.Keywords;
                Abilities        = copy.Abilities;
                MinimumUnitCount = copy.MinimumUnitCount;
                MaximumUnitCount = copy.MaximumUnitCount;
                Powerlevel       = copy.Powerlevel;
                MatchedPoints    = copy.MatchedPoints;
                BonusCp          = copy.BonusCp;
                BattleRole       = copy.BattleRole;

                SpecialRules    = new List <Rule>();
                ListEntries     = new UnitModels();
                WargearUpgrades = new Upgrades();

                foreach (Rule rule in copy.SpecialRules)
                {
                    SpecialRules.Add(new Rule(rule));
                }

                foreach (UnitModel unitMod in copy.ListEntries)
                {
                    ListEntries.Add(new UnitModel(unitMod));
                }

                IsUnique = copy.IsUnique;

                Id = Guid.NewGuid().ToString();
            }
        }
Beispiel #24
0
 public Unit()
 {
     SpecialRules    = new List <Rule>();
     ListEntries     = new UnitModels();
     WargearUpgrades = new Upgrades();
     Id = Guid.NewGuid().ToString();
 }
Beispiel #25
0
 public UpgradeTier(Upgrades type, T data, float cost, UpgradeTier <T> nextTier)
 {
     this.type     = type;
     this.data     = data;
     this.cost     = cost;
     this.nextTier = nextTier;
 }
    /// <summary>
    /// Setup the menu
    /// </summary>
    void Start()
    {
        int_difficulty = PlayerPrefs.GetInt("difficulty", 2);
        //Add listeners
        Messenger.AddListener("setBlack", setBlack);


        smallFont.fontSize = 25;
        largeFont.fontSize = 40;

        //White font will stick out on our black background
        smallFont.normal.textColor = Color.white;
        largeFont.normal.textColor = Color.white;

        //format the button so that it's visible


        startY = -Screen.height / 2 + 120;
        //initialize GameObject_upgrades and Upgrades_upgrades
        GameObject_upgrades = GameObject.FindGameObjectWithTag("Upgrades");        //GameObject_upgrades = GameObject.Find ("Upgrades-Score");

        //if we have now upgrades object load the prefab for upgrades onto the scene
        if (GameObject_upgrades == null)
        {
            Debug.LogWarning("Warning: Upgrades GameObject could not be found");
            GameObject_upgrades = Instantiate(Resources.Load("Upgrades-Score")) as GameObject;
        }

        Upgrades_upgrades = GameObject_upgrades.GetComponent <Upgrades>();

        //no matter what we have the upgrades object so we're good to load everything
        guiReady = true;
    }
Beispiel #27
0
        internal bool CanBeUpgraded(UpgradePair upgrade, bool left)
        {
            if (upgrade == null)
            {
                throw new ArgumentNullException();
            }
            if (_upgrades.All(x => x.UpgradeType != upgrade.UpgradeType))
            {
                return(true);
            }
            if (_upgrades.Count(x => x.UpgradeType != upgrade.UpgradeType) >= 2)
            {
                return(false);
            }

            var u = Upgrades.First(x => x.UpgradeType == upgrade.UpgradeType) as UpgradePair;

            if (left)
            {
                return(u.LeftAnimal != this);
            }
            else
            {
                return(u.RightAnimal != this);
            }
        }
		public bool HasUpgarde(Upgrades upgrade)
		{
			for (int i = 0; i < Count.Upgrade; i++)
				if (Upgrade[i] == upgrade)
					return true;
			return false;
		}
Beispiel #29
0
    protected void UpdateItemPrice(Upgrades upgrade)
    {
        switch (upgrade.Stat)
        {
        case UpgradeStats.HealthUpgrade:
            upgrade.Price = upgrade.BasePrice + (int)(upgrade.BasePrice * GetCurrentStatInfo(upgrade.Stat) / 35);
            break;

        case UpgradeStats.ArmourUpgrade:
            upgrade.Price = upgrade.BasePrice + (int)(upgrade.BasePrice * GetCurrentStatInfo(upgrade.Stat) / 20);
            break;

        case UpgradeStats.AgilityUpgrade:
            upgrade.Price = upgrade.BasePrice + (int)(upgrade.BasePrice * GetCurrentStatInfo(upgrade.Stat) / 10);
            break;

        case UpgradeStats.JumpingUpgrade:
            upgrade.Price = upgrade.BasePrice + (int)(upgrade.BasePrice * GetCurrentStatInfo(upgrade.Stat) / 50);
            break;

        case UpgradeStats.WeaponUpgrade:
            upgrade.Price = upgrade.BasePrice + (int)(upgrade.BasePrice * GetCurrentStatInfo(upgrade.Stat) / 10);
            break;

        case UpgradeStats.RangedUpgrade:
            upgrade.Price = upgrade.BasePrice + (int)(upgrade.BasePrice * GetCurrentStatInfo(upgrade.Stat) / 10);
            break;
        }
    }
Beispiel #30
0
    public void UpdateIcon()
    {
        Upgrades upg = eventSystem.GetComponent <Upgrades>();

        Upgrades.Upgrade up;

        // Set health upgrades
        int hpUpg = PlayerPrefs.GetInt("healthUpgrade", 0);

        up = upg.GetUpgrade(hpUpg);
        sleeve.GetComponent <Image>().color = new Color(up.r / 255f, up.g / 255f, up.b / 255f);        // Impart la 255 ca sa dau valoari intre 0 si 1


        // Set shield upgrades
        int guardUpg = PlayerPrefs.GetInt("shieldUpgrade", 0);

        up = upg.GetUpgrade(guardUpg);
        shield.GetComponent <Image>().color = new Color(up.r / 255f, up.g / 255f, up.b / 255f);

        // Set weapon
        Image weaponImg = weaponObj.GetComponent <Image>();

        weaponImg.sprite = weapons[PlayerPrefs.GetInt("weaponNo", 0)];
        weaponImg.SetNativeSize();

        Vector2 size         = weaponObj.GetComponent <RectTransform>().sizeDelta;
        Vector2 pixelPivot   = weaponObj.GetComponent <Image>().sprite.pivot;
        Vector2 percentPivot = new Vector2(pixelPivot.x / size.x, pixelPivot.y / size.y);

        weaponObj.GetComponent <RectTransform>().pivot = percentPivot;
    }
Beispiel #31
0
    protected Transform CreateButton(Upgrades upgrade, int shopIndex)
    {
        UpdateItemPrice(upgrade);
        Transform     shopItemTransform     = Instantiate(shopItemTemplate, container);
        RectTransform shopItemRectTransform = shopItemTransform.GetComponent <RectTransform>();

        float shopItemHeight = 100f;

        shopItemRectTransform.anchoredPosition = new Vector2(0, -shopItemHeight * shopIndex);

        shopItemTransform.Find("nameText").GetComponent <TextMeshProUGUI>().SetText(upgrade.UpgradeName);
        shopItemTransform.Find("priceText").GetComponent <TextMeshProUGUI>().SetText(upgrade.Price.ToString());
        shopItemTransform.Find("itemIcon").GetComponent <Image>().sprite = upgrade.Sprite;
        if (GetCurrentStatInfo(upgrade.Stat) < upgrade.ItemCap && upgrade.Price <= playerStats.GetPlayerMoney())
        {
            shopItemTransform.Find("currentStats").GetComponent <TextMeshProUGUI>().SetText($"{upgrade.UpgradeDescription} {GetCurrentStatInfo(upgrade.Stat)}/{upgrade.ItemCap}");
        }
        else if (GetCurrentStatInfo(upgrade.Stat) >= upgrade.ItemCap)
        {
            shopItemTransform.Find("background").GetComponent <Image>().color = Color.red;
            shopItemTransform.Find("currentStats").GetComponent <TextMeshProUGUI>().SetText("Maximum limit reaced");
        }
        else if (upgrade.Price > playerStats.GetPlayerMoney())
        {
            shopItemTransform.Find("background").GetComponent <Image>().color = Color.red;
            shopItemTransform.Find("currentStats").GetComponent <TextMeshProUGUI>().SetText("Insufficient funds");
        }
        shopItemTransform.GetComponent <Button>().onClick.AddListener(() =>
        {
            TryBuyUpgrade(upgrade, shopIndex);
        });
        return(shopItemTransform);
    }
    // Use this for initialization
    void Start()
    {
        //gamestate testing

        mCurBonusSubject = BonusSubject.Melee;
        DynamicUpgrades = new int[mSubjectMax, mBonusMax];
        OriginalUpgrades = new int[mSubjectMax, mBonusMax];
        mCurUpgrades =  GameObject.Find("Store").GetComponent<Upgrades>();
        mCurUpgrades.SetStoreArray(ref DynamicUpgrades);
        mCurUpgrades.SetStoreArray(ref OriginalUpgrades);
    }
Beispiel #33
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else if (instance != this)
     {
         Destroy(this.gameObject);
     }
 }
Beispiel #34
0
    protected override void Awake()
    {
        base.Awake();
        upgradeResource = GetComponentInChildren<UpgradeResource>();
        upgrades = GetComponentInChildren<Upgrades>();
        collectResources = GetComponent<CollectResources>();
        sprite = GetComponent<SpriteRenderer>();

        upgradeMenu = transform.Find("UpgradeMenu").gameObject;
        upgradeMenu.SetActive(false);

        InvokeRepeating("RecoverHealth", 0, healthRecoverRate);
    }
 protected virtual void Awake()
 {
     upgrades = transform.parent.GetComponent<Upgrades>();
     totalResources = GameObject.Find("Total Resources").GetComponent<TotalResources>();
     foreach (Transform textObj in transform)
     {
         if (textObj.gameObject.name == "Points") {
             textObj.GetComponent<TextMesh>().text = pointsSpendOnThis + "/" + upgrades.TotalPoints;
         }
         else if (textObj.gameObject.name == "Price") {
             price = int.Parse(textObj.GetComponent<TextMesh>().text);
         }
     }
 }
    public void Save()
    {
        BinaryFormatter bf = new BinaryFormatter ();

        FileStream file = File.Open (Application.persistentDataPath + "/playerInfo.dat", FileMode.Create);
        PlayerData data = new PlayerData ();
        data.gold = gold;
        data.goldperclick = goldperclick;
        data.karma = karma;
        for (int i=0; i<items.Length; i++) {
            Items item = new Items ();
            UpgradeManager script = items[i].GetComponent<UpgradeManager>();
            item.id = script.id;
            item.amount = script.count;
            data.itemsz.Add(item);

        }
        for (int i=0; i<labels.Length; i++) {
            Labels label = new Labels ();
            LayerManager script = labels[i].GetComponent<LayerManager>();
            label.purchased = script.purchased;
            data.labs.Add(label);
        }
        upgrades = GameObject.FindGameObjectsWithTag ("Upgrade") as GameObject[];
        for (int i=0; i<upgrades.Length; i++) {
            Upgrades upgrade = new Upgrades ();
            ItemManager script = upgrades[i].GetComponent<ItemManager>();
            //Debug.Log ("I: " +  i);
            //Debug.Log ("Script id: "+ script.id);
            //Debug.Log ("Script count: "+ script.count);
            upgrade.id = script.id;
            upgrade.amount = script.count;
            data.upg.Add(upgrade);

            //Debug.Log ("Upgrade id: " + upgrade.id);
            //Debug.Log ("Upgrade amount: " + upgrade.amount);

        }
        Debug.Log ("SAVED");
        data.fte1 = fte1;
        data.fte2 = fte2;
        data.fte3 = fte3;
        data.fte4 = fte4;
        data.fte5 = fte5;
        data.fte2Arrow = fte2Arrow;
        data.fte3Arrow = fte3Arrow;
        data.extra = extra;
        data.date = date.ToBinary().ToString();
        data.upg.ToArray ();
        data.itemsz.ToArray ();
        data.pis_current = pis_current;
        bf.Serialize (file, data);

        file.Close ();
    }