Beispiel #1
0
    public void SetCarChoice(int carNum, bool isMultiplayer)
    {
        CarData data = CarDataLookup.Instance.FindCarData(carStyle);

        upgradeLevel = (UpgradeLevel)carNum;
        if (data != null)
        {
            SpriteRenderer visual = GetComponentInChildren <SpriteRenderer>();
            if (visual)
            {
                visual.sprite = data.GetVisual(carColor);
            }
            PolygonCollider2D collider = GetComponentInChildren <PolygonCollider2D>();
            if (collider != null)
            {
                collider.SetPath(0, data.points.ToArray());
            }

            if (isMultiplayer)
            {
                // Car choice has only a visual effect in multiplayer games
                _carSpeed = data.GetMaxSpeed(0);
            }
            else
            {
                _carSpeed = data.GetMaxSpeed(carNum - 1);
            }
        }
    }
        private void Init()
        {
            this.weapon     = owner.Mine as MineLauncher;
            this.lastLevel  = weapon.UpgradeLevel;
            this.rand       = owner.SceneMgr.GetRandomGenerator();
            this.targeting  = false;
            this.shooting   = false;
            this.steps      = 0;
            this.mine       = 0;
            this.shootingCd = 0;

            weapon.AddClickListener(this);
            owner.SceneMgr.AddMoveListener(this);

            nextTarget   = new Point();
            nextTarget.Y = 1;
            nextTarget.X = FastMath.LinearInterpolate(minWidth, maxWidth, rand.NextDouble());

            if (owner.GetPosition() == PlayerPosition.RIGHT)
            {
                minWidth = 0;
                maxWidth = SharedDef.VIEW_PORT_SIZE.Width * SharedDef.MINE_ACTIVE_RADIUS;
            }
            else
            {
                minWidth = SharedDef.VIEW_PORT_SIZE.Width - (SharedDef.VIEW_PORT_SIZE.Width * SharedDef.MINE_ACTIVE_RADIUS);
                maxWidth = SharedDef.VIEW_PORT_SIZE.Width;
            }
        }
    public static void drawUpgradeSpecs(Editor editor, UpgradeLevel.Specs specs, int[] prices = null)
    {
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Specs:");
        EditorGUILayout.Space();

        drawUpgradeInfoFloat(editor, "Magnet Radius", ref specs.magnetRadius);
        drawPriceInfo(editor, prices, UpgradeLevel.Type.Magnet);
        EditorGUILayout.Space();

        drawUpgradeInfoInt(editor, "Carrot Sprays", ref specs.carrotSprayCount);
        drawPriceInfo(editor, prices, UpgradeLevel.Type.CarrotSpray);
        EditorGUILayout.Space();

        drawUpgradeInfoInt(editor, "Bubble Gums", ref specs.bubbleGumCount);
        drawPriceInfo(editor, prices, UpgradeLevel.Type.BubbleGum);
        EditorGUILayout.Space();

        drawUpgradeInfoFloat(editor, "Fart Capacity", ref specs.fartCapacity);
        drawUpgradeInfoFloat(editor, "Fart Force", ref specs.fartForce);
        drawPriceInfo(editor, prices, UpgradeLevel.Type.PowerUpFart);
        EditorGUILayout.Space();

        drawUpgradeInfoFloat(editor, "Glide Capacity", ref specs.glideCapacity);
        drawUpgradeInfoFloat(editor, "Glide Force", ref specs.glideForce);
        drawPriceInfo(editor, prices, UpgradeLevel.Type.PowerUpGlide);

        EditorGUILayout.Space();
    }
Beispiel #4
0
        private void LevelsTabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            var ind = LevelsTabControl.SelectedIndex;

            if (ind == -1)
            {
                return;
            }
            ActiveGroup    = null;
            ActiveGroupInd = -1;
            ActiveSub      = null;
            if (ind < LevelTabStart)
            {
                ActiveLevel = null;
                if (LevelsTabControl.SelectedTab == GroupPage)
                {
                    UpdateTuningEntries(false, false);
                    RenderGroups();
                }
            }
            else if (ind == LevelsTabControl.TabPages.Count - 1 && LevelsTabControl.TabPages.Count > LevelTabStart)
            {
                AddUpgrade();
            }
            else
            {
                ActiveLevel = ActiveUpgrades.Upgrades[ind - LevelTabStart];
            }
            UpdateSubsList();
        }
Beispiel #5
0
 public void setFromUpgradeSpecs(UpgradeLevel.Specs specs, bool setTimeToCapacity = true)
 {
     this.specs = specs;
     if (setTimeToCapacity) {
       fartTime = specs.fartCapacity;
       glideTime = specs.glideCapacity;
     }
 }
Beispiel #6
0
 public Stat(UpgradeLevel level, PlayerStats type, string text, float min, float max)
 {
     this.level = level;
     this.type  = type;
     this.text  = text;
     this.min   = min;
     this.max   = max;
 }
Beispiel #7
0
 public void ReadObject(NetIncomingMessage msg)
 {
     level = (UpgradeLevel)msg.ReadInt32();
     type  = (PlayerStats)msg.ReadInt32();
     text  = msg.ReadString();
     min   = msg.ReadFloat();
     max   = msg.ReadFloat();
 }
Beispiel #8
0
 public HookLauncher(SceneMgr mgr, Player owner)
 {
     SceneMgr     = mgr;
     Owner        = owner;
     Name         = "Hook launcher";
     DeviceType   = DeviceType.HOOK;
     UpgradeLevel = UpgradeLevel.LEVEL1;
     ReloadTime   = 0;
 }
        public void Update(float tpf)
        {
            if (!Enable)
            {
                return;
            }

            if (lastLevel != owner.Mine.UpgradeLevel)
            {
                weapon    = owner.Mine as MineLauncher;
                lastLevel = weapon.UpgradeLevel;
                weapon.AddClickListener(this);
            }

            if (shooting)
            {
                proccesShooting(tpf);
                return;
            }

            if (InnerCD > 0)
            {
                InnerCD          -= tpf;
                weapon.ReloadTime = weapon.Owner.Data.MineCooldown;
                owner.SceneMgr.BeginInvoke(new Action(() => cooldownVisualiser.SetPercentage(1 - (InnerCD / SharedDef.MINE_VOLLEY_CD))));
                if (InnerCD <= 0)
                {
                    owner.SceneMgr.BeginInvoke(new Action(() =>
                    {
                        launchArea.SetPosition(nextTarget);
                        launchArea.Visibility = Visibility.Visible;
                    }));
                }

                return;
            }

            if (owner.Mine != weapon)
            {
                weapon = owner.Mine as MineLauncher;
            }

            if (weapon.IsReady())
            {
                weapon.Shoot(nextTarget);

                nextTarget.X = FastMath.LinearInterpolate(minWidth, maxWidth, rand.NextDouble());
                owner.SceneMgr.BeginInvoke(new Action(() => launchArea.SetPosition(nextTarget)));
            }
            else
            {
                float percentage = 1 - (weapon.ReloadTime / weapon.Owner.Data.MineCooldown);
                owner.SceneMgr.BeginInvoke(new Action(() => launchArea.SetPercentage(percentage)));
            }

            owner.SceneMgr.BeginInvoke(new Action(() => cooldownVisualiser.Update(tpf)));
        }
        private string GetCharsForLevel(UpgradeLevel lvl)
        {
            string s = string.Empty;

            for (int i = 0; i < (int)lvl; ++i)
            {
                s += "I";
            }
            return(s);
        }
Beispiel #11
0
        private void AddUpgrade()
        {
            if (ActiveUpgrades == null)
            {
                return;
            }
            var newLevel = new UpgradeLevel();

            ActiveUpgrades.Upgrades.Add(newLevel);
            PrepareTabs();
            UpdateFile();
        }
 public PlayerOverviewData(string name, int score, int gold, bool active, int played, int won,
                           UpgradeLevel mine, UpgradeLevel cannon, UpgradeLevel hook)
 {
     Name        = name;
     Score       = score;
     Gold        = gold;
     Active      = active;
     Played      = played;
     Won         = won;
     MineLevel   = mine;
     CannonLevel = cannon;
     HookLevel   = hook;
 }
Beispiel #13
0
 public void ensureDataConsistency()
 {
     if (upgradeLevels == null) {
       upgradeLevels = new UpgradeLevel[UpgradeLevel.NumLevels];
       for (int i = 0; i < UpgradeLevel.NumLevels; ++i)
     upgradeLevels[i] = new UpgradeLevel();
     }
     else if (upgradeLevels.Length != UpgradeLevel.NumLevels) {
       int oldSize = upgradeLevels.Length;
       Array.Resize<UpgradeLevel>(ref upgradeLevels, UpgradeLevel.NumLevels);
       for (int i = oldSize; i < UpgradeLevel.NumLevels; ++i)
     upgradeLevels[i] = new UpgradeLevel();
     }
 }
Beispiel #14
0
 void ActivateTowerUpgrades(bool activate)
 {
     foreach (TypeToInfo infoType in info)
     {
         if (infoType.type == currentType)
         {
             foreach (GameObject upgrade in infoType.upgrades)
             {
                 upgrade.SetActive(activate);
             }
         }
     }
     UpgradeLevel.UpdateInfo();
 }
Beispiel #15
0
        private Stat GetStatForDeviceTypeAndLevel(DeviceType type, UpgradeLevel upgradeLevel)
        {
            switch (type)
            {
            case DeviceType.MINE:
                switch (upgradeLevel)
                {
                case UpgradeLevel.LEVEL1:
                case UpgradeLevel.LEVEL2:
                case UpgradeLevel.LEVEL3:
                default:
                    return(allStats[(PlayerStats)sceneMgr.GetRandomGenerator().Next((int)PlayerStats.MINE_1_MIN + 1, (int)PlayerStats.MINE_1_MAX)]);
                }

            case DeviceType.CANNON:
                switch (upgradeLevel)
                {
                case UpgradeLevel.LEVEL3:
                case UpgradeLevel.LEVEL1:
                case UpgradeLevel.LEVEL2:
                default:
                    return(allStats[(PlayerStats)sceneMgr.GetRandomGenerator().Next((int)PlayerStats.CANNON_1_MIN + 1, (int)PlayerStats.CANNON_1_MAX)]);
                }

            case DeviceType.HOOK:
                switch (upgradeLevel)
                {
                case UpgradeLevel.LEVEL1:
                case UpgradeLevel.LEVEL2:
                case UpgradeLevel.LEVEL3:
                default:
                    return(allStats[(PlayerStats)sceneMgr.GetRandomGenerator().Next((int)PlayerStats.HOOK_1_MIN + 1, (int)PlayerStats.HOOK_1_MAX)]);
                }

            case DeviceType.HEALING_KIT:
                switch (upgradeLevel)
                {
                case UpgradeLevel.LEVEL1:
                case UpgradeLevel.LEVEL2:
                case UpgradeLevel.LEVEL3:
                default:
                    return(allStats[(PlayerStats)sceneMgr.GetRandomGenerator().Next((int)PlayerStats.HEALING_KIT_1_MIN + 1, (int)PlayerStats.HEALING_KIT_1_MAX)]);
                }

            default:
                throw new Exception("Received invalid DeviceType");
            }
        }
Beispiel #16
0
        private void LevelsTabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            var ind = LevelsTabControl.SelectedIndex;

            if (ind == -1)
            {
                return;
            }
            if (ind == 0)
            {
                ActiveLevel = null;
            }
            else if (ind == LevelsTabControl.TabPages.Count - 1 && LevelsTabControl.TabPages.Count > 1)
            {
                AddUpgrade();
            }
            else
            {
                ActiveLevel = ActiveUpgrades.Upgrades[ind - 1];
            }
            UpdateSubsList();
        }
    public UpgradeLevel GetUpgrade(UpgradeType type)
    {
        UpgradeLevel upgrade = null;

        switch (type)
        {
        case UpgradeType.Collect_Speed:
            upgrade = speedUpgrade;
            break;

        case UpgradeType.Collect_Radius:
            upgrade = radiusUpgrade;
            break;

        case UpgradeType.Collect_Efficiency:
            upgrade = efficiencyUpgrade;
            break;

        case UpgradeType.Collect_Weight:
            upgrade = weightUpgrade;
            break;

        case UpgradeType.Particle_Speed:
            upgrade = accelerationUpgrade;
            break;

        case UpgradeType.Particle_Stability:
            upgrade = stabilityUpgrade;
            break;

        case UpgradeType.Time_Dilation:
            upgrade = timeUpgrade;
            break;
        }

        return(upgrade);
    }
        public RuntimeUpgradeLevel(UpgradeIff file, UpgradeLevel level, GameObjectResource res, Content content)
        {
            Level = level;
            if (Level.Price.Length == 0)
            {
                throw new Exception("Missing price.");
            }
            if (Level.Price[0] == 'R' || Level.Price[0] == '$')
            {
                if (Level.Price[0] == 'R')
                {
                    Relative = true;
                }
                if (!int.TryParse(Level.Price.Substring(1), out Price))
                {
                    throw new Exception("Could parse literal upgrade level price! " + Level.Price);
                }
            }
            else
            {
                uint guid;
                if (!uint.TryParse(Level.Price, System.Globalization.NumberStyles.HexNumber, null, out guid))
                {
                    throw new Exception("Could parse guid for upgrade level price! " + Level.Price);
                }
                var item = content.WorldCatalog.GetItemByGUID(guid);
                if (item == null)
                {
                    throw new Exception("Could not find catalog entry for price reference! This error is fatal because a 0 price upgrade would be really bad." + Level.Price);
                }
                Price = (int)item.Value.Price;
            }

            Ads = Level.Ad.Split(';');

            Subs = RuntimeUpgradeFile.LoadSubs(Level.Subs, file.Groups, res);
        }
 public void Delete()
 {
     UpgradeLevel.DeleteTowerUpgrades();
 }
 public static void drawPriceInfo(Editor editor, int[] prices, UpgradeLevel.Type type)
 {
     if (prices != null)
       prices[(int)type] = EditorGUILayout.IntField("Price", prices[(int)type]);
 }