}     // End RemoveUnitFromSquad()

    /**
     * Reset all game variables (except PlayerCurrentLevelName) to start a new level...
     */
    public static void ResetGameVars()
    {
        SquadClicked       = null;
        LevelWon           = false;
        GameInPlay         = true;
        GameOverReason     = "";
        PlayerReady        = false;
        PathArrows         = new List <GameObject>();
        AllUnits           = new List <Unit>();
        BomberUnit         = new Unit(UnitTypes["bomber"]);
        UnitTypeClicked    = "";
        UnitBoxClicked     = -1;
        BomberDeployed     = false;
        SquadsDeployed     = new List <string>();
        SpotFilled         = new string[18];
        SquadDeployClicked = null;
        LastSquadKey       = "Alpha";
        Stop = false;

        Squads = new Dictionary <string, Unit[]> {
            { "alpha", new Unit[SquadMaxUnits] },
            { "beta", new Unit[SquadMaxUnits] },
            { "omega", new Unit[SquadMaxUnits] },
        };

        UnitsRemaining = new Dictionary <string, int> {
            { "bomber", LevelConfig.NumberOfUnits["bomber"] },
            { "ldu", LevelConfig.NumberOfUnits["ldu"] },
            { "rifiler", LevelConfig.NumberOfUnits["rifiler"] },
            { "special forces", LevelConfig.NumberOfUnits["special forces"] },
            { "firefighter", LevelConfig.NumberOfUnits["firefighter"] },
            { "commando", LevelConfig.NumberOfUnits["commando"] },
        };

        DeployingPath = new Dictionary <int, bool> ();
    }     // End ResetGameVars()
        void ReleaseDesignerOutlets()
        {
            if (NetworkUpdateButton != null)
            {
                NetworkUpdateButton.Dispose();
                NetworkUpdateButton = null;
            }

            if (Authentication != null)
            {
                Authentication.Dispose();
                Authentication = null;
            }

            if (BootFileLabel != null)
            {
                BootFileLabel.Dispose();
                BootFileLabel = null;
            }

            if (ConfigFileLabel != null)
            {
                ConfigFileLabel.Dispose();
                ConfigFileLabel = null;
            }

            if (DefaultGateway != null)
            {
                DefaultGateway.Dispose();
                DefaultGateway = null;
            }

            if (DeployButton != null)
            {
                DeployButton.Dispose();
                DeployButton = null;
            }

            if (DeviceType != null)
            {
                DeviceType.Dispose();
                DeviceType = null;
            }

            if (EnableDHCP != null)
            {
                EnableDHCP.Dispose();
                EnableDHCP = null;
            }

            if (EncryptConfig != null)
            {
                EncryptConfig.Dispose();
                EncryptConfig = null;
            }

            if (Encryption != null)
            {
                Encryption.Dispose();
                Encryption = null;
            }

            if (FirmwareStatus != null)
            {
                FirmwareStatus.Dispose();
                FirmwareStatus = null;
            }

            if (FlashFileLabel != null)
            {
                FlashFileLabel.Dispose();
                FlashFileLabel = null;
            }

            if (FreeSlots != null)
            {
                FreeSlots.Dispose();
                FreeSlots = null;
            }

            if (MacAddress != null)
            {
                MacAddress.Dispose();
                MacAddress = null;
            }

            if (NetworkKey != null)
            {
                NetworkKey.Dispose();
                NetworkKey = null;
            }

            if (NetworkMacAddress != null)
            {
                NetworkMacAddress.Dispose();
                NetworkMacAddress = null;
            }

            if (NetworkValue != null)
            {
                NetworkValue.Dispose();
                NetworkValue = null;
            }

            if (Output != null)
            {
                Output.Dispose();
                Output = null;
            }

            if (Passphrase != null)
            {
                Passphrase.Dispose();
                Passphrase = null;
            }

            if (PrimaryDNS != null)
            {
                PrimaryDNS.Dispose();
                PrimaryDNS = null;
            }

            if (RadioA != null)
            {
                RadioA.Dispose();
                RadioA = null;
            }

            if (RadioB != null)
            {
                RadioB.Dispose();
                RadioB = null;
            }

            if (RadioG != null)
            {
                RadioG.Dispose();
                RadioG = null;
            }

            if (RadioN != null)
            {
                RadioN.Dispose();
                RadioN = null;
            }

            if (ReKeyInternal != null)
            {
                ReKeyInternal.Dispose();
                ReKeyInternal = null;
            }

            if (SaveConfigurationButton != null)
            {
                SaveConfigurationButton.Dispose();
                SaveConfigurationButton = null;
            }

            if (SecondaryDNS != null)
            {
                SecondaryDNS.Dispose();
                SecondaryDNS = null;
            }

            if (SSID != null)
            {
                SSID.Dispose();
                SSID = null;
            }

            if (StaticIPAddress != null)
            {
                StaticIPAddress.Dispose();
                StaticIPAddress = null;
            }

            if (SubnetMask != null)
            {
                SubnetMask.Dispose();
                SubnetMask = null;
            }

            if (UpdateFirmwareButton != null)
            {
                UpdateFirmwareButton.Dispose();
                UpdateFirmwareButton = null;
            }
        }
Beispiel #3
0
    }     // End OnHover()

    void OnClick()
    {
        // If waiting, return...
        if (GameVars.DeployingPath.ContainsKey(PathNumber) && GameVars.DeployingPath[PathNumber] == true)
        {
            return;
        }

        if (UICamera.currentTouchID == -1)           // Only on a left-click

        // Determine the "Deploy" Button Clicked
        {
            string whichSquad = GameVars.SquadDeployClicked.squadName;

            // If Null, return.
            if (GameVars.SquadDeployClicked == null)
            {
                return;
            }

            // If the squad name isn't "alpha", "beta", or "omega" throw an exception...
            if (GameVars.Squads[whichSquad] == null)
            {
                throw new UnityException("Unknown Squad");
            }

            // Instantiate the squad's units...
            if (GameVars.Squads[whichSquad].Length > 0)
            {
                DeployButton src = GameObject.Find("BuildSquad" + FirstLetterToUpper(whichSquad) + "/DeploySquad").GetComponent <DeployButton>();

                src.UnitFactory(PathNumber, GameVars.Squads[whichSquad], new Vector3(gameObject.transform.position.x - .1f, gameObject.transform.position.y, gameObject.transform.position.z), new Quaternion(0, 0, 0, 0));

                // Disable the deploy button now,
                GameVars.SquadDeployClicked.GetComponent <UIImageButton>().isEnabled = false;


                // Re-enable all + buttons
                foreach (GameObject go in GameObject.FindGameObjectsWithTag("plusButton"))
                {
                    if (disabled.IndexOf(go.GetComponent <UIImageButton>()) < 0)
                    {
                        go.GetComponent <UIImageButton>().isEnabled = true;
                    }
                }


                // Now hide the "Select A Path" Sprite...
                NGUITools.SetActive(selectText, false);
            }

            int squadStartI = 0;

            switch (whichSquad)
            {
            case "alpha":
                squadStartI = 1;
                break;

            case "beta":
                squadStartI = 7;
                break;

            case "omega":
                squadStartI = 13;
                break;
            }

            // Now disable the add buttons for this squad
            for (int i = squadStartI; i <= GameVars.SquadMaxUnits + squadStartI - 1; i++)
            {
                UIImageButton plusButton = GameObject.Find("AddUnit" + i).GetComponent <UIImageButton>();

                if (plusButton.disabledSprite == "AddUnit")
                {
                    plusButton.disabledSprite = "NoAdd";
                }

                plusButton.isEnabled = false;
                disabled.Add(plusButton);
            }

            // Now hide the Arrows...
            foreach (GameObject g in GameVars.PathArrows)
            {
                NGUITools.SetActive(g, false);
            }

            // Indicate that this squad was deployed
            GameVars.SquadsDeployed.Add(whichSquad);
            Console.Push(GameVars.UCFirst(whichSquad) + " squad has been deployed");


            wait.spriteName = "SelectAPath";
            wait.MakePixelPerfect();
            wait.MarkAsChanged();
        } // End if left click
    }     // End OnClick