예제 #1
0
 private void AttackUnit(GameObject closestUnit)
 {
     if (closestUnit.tag == "TeamA" || closestUnit.tag == "TeamB")
     {
         UnitAController unitInfo   = closestUnit.GetComponent <UnitAController>();
         Vector3         currentPos = transform.position;
         float           dist       = Vector3.Distance(closestUnit.transform.position, currentPos);
         if (this.unitType == "Ranged")
         {
             if (dist <= rangedAttackRange)
             {
                 unitInfo.Health -= rangedAttackDamage;
                 if (unitInfo.Health <= 0)
                 {
                     Debug.Log("Killed");
                     Destroy(closestUnit);
                 }
             }
             else
             {
                 Move();
             }
         }
         else
         {
             if (dist <= meleeAttackRange)
             {
                 unitInfo.Health -= meleeAttackDamage;
                 if (unitInfo.Health <= 0)
                 {
                     Debug.Log("Killed by melee");
                     Destroy(closestUnit);
                 }
             }
             else
             {
                 Move();
             }
         }
     }
     else if (closestUnit.tag == "Wizard")
     {
         WizardController unitInfo   = closestUnit.GetComponent <WizardController>();
         Vector3          currentPos = transform.position;
         float            dist       = Vector3.Distance(closestUnit.transform.position, currentPos);
         if (this.unitType == "Ranged")
         {
             if (dist <= rangedAttackRange)
             {
                 unitInfo.Health -= rangedAttackDamage;
                 if (unitInfo.Health <= 0)
                 {
                     Debug.Log("Killed");
                     Destroy(closestUnit);
                 }
             }
             else
             {
                 Move();
             }
         }
         else
         {
             if (dist <= meleeAttackRange)
             {
                 unitInfo.Health -= meleeAttackDamage;
                 if (unitInfo.Health <= 0)
                 {
                     Debug.Log("Killed by melee");
                     Destroy(closestUnit);
                 }
             }
             else
             {
                 Move();
             }
         }
     }
     else
     {
         BuildingInfo unitInfo   = closestUnit.GetComponent <BuildingInfo>();
         Vector3      currentPos = transform.position;
         float        dist       = Vector3.Distance(closestUnit.transform.position, currentPos);
         if (this.unitType == "Ranged")
         {
             if (dist <= rangedAttackRange)
             {
                 unitInfo.Health -= rangedAttackDamage;
                 if (unitInfo.Health <= 0)
                 {
                     Debug.Log("Killed");
                     Destroy(closestUnit);
                 }
             }
             else
             {
                 Move();
             }
         }
         else
         {
             if (dist <= meleeAttackRange)
             {
                 unitInfo.Health -= meleeAttackDamage;
                 if (unitInfo.Health <= 0)
                 {
                     Debug.Log("Killed by melee");
                     Destroy(closestUnit);
                 }
             }
             else
             {
                 Move();
             }
         }
     }
 }
예제 #2
0
        /// <summary>
        /// Runs the wizard.
        /// </summary>
        public void Run()
        {
            if (!(configuration.Security is InternalServerSecurity))
            {
                if (MessageBox.Show("Setting permissions is only valid for internal security, do you want to change to internal security now?",
                                    "Invalid security manager",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Warning) == DialogResult.No)
                {
                    return;
                }
                else
                {
                    changeManager = true;
                }
            }
            var steps = new List <IStep>();

            controller = new WizardController(steps);

            // Welcome text
            steps.Add(new TextDisplayStep("This wizard will guide you through the steps of setting permissions for a project in this configuration.", "Welcome"));
            settings.AddRange(new string[] {
                "No project selected",
                "No default permission"
            });

            // Select the projec
            var projectSelection     = new SelectProjectStep(configuration);
            var projectSelectionStep = new TemplateStep(projectSelection, 0, "Select Project");

            projectSelectionStep.NextHandler += () =>
            {
                settings[0] = string.Format("Configuring project '{0}'", projectSelection.SelectedProject);
                return(true);
            };
            steps.Add(projectSelectionStep);

            // Default project permission
            var defaultProjectPermission = new SelectionStep("Default Project Permission",
                                                             "What do you want as the default project permission:",
                                                             "None",
                                                             "Allow",
                                                             "Deny",
                                                             "Inherit");

            defaultProjectPermission.NextHandler += () =>
            {
                switch ((string)defaultProjectPermission.Selected)
                {
                case "None":
                    settings[1] = "No default permission";
                    break;

                case "Allow":
                    settings[1] = "Default project permission is allow";
                    break;

                case "Deny":
                    settings[1] = "Default project permission is deny";
                    break;

                case "Inherit":
                    settings[1] = "Default project permission is inherit";
                    break;
                }
                return(true);
            };
            steps.Add(defaultProjectPermission);

            // Set the force/abort build permissions
            var defaultPermission = new SelectUsersStep(configuration);

            defaultPermission.Caption = "What are the default permissions:";
            var defaultPermissionStep = new TemplateStep(defaultPermission, 0, "Set force/abort build permissions");

            defaultPermissionStep.NextHandler += () =>
            {
                return(true);
            };
            steps.Add(defaultPermissionStep);

            // Set the force/abort build permissions
            var forceBuildPermission = new SelectUsersStep(configuration);

            forceBuildPermission.Caption = "What are the allowed permissions for force/abort build:";
            var forceBuildPermissionStep = new TemplateStep(forceBuildPermission, 0, "Set force/abort build permissions");

            forceBuildPermissionStep.NextHandler += () =>
            {
                return(true);
            };
            steps.Add(forceBuildPermissionStep);

            // Set the start/stop project permissions
            var startProjectPermission = new SelectUsersStep(configuration);

            startProjectPermission.Caption = "Which users are allowed to start/stop builds:";
            var startProjectPermissionStep = new TemplateStep(startProjectPermission, 0, "Set start/stop project permissions");

            startProjectPermissionStep.NextHandler += () =>
            {
                return(true);
            };
            steps.Add(startProjectPermissionStep);

            // Set the send message permissions
            var sendMessagePermission = new SelectUsersStep(configuration);

            sendMessagePermission.Caption = "What are the allowed permissions for sending messages:";
            var sendMessagePermissionStep = new TemplateStep(sendMessagePermission, 0, "Set send message permissions");

            sendMessagePermissionStep.NextHandler += () =>
            {
                return(true);
            };
            steps.Add(sendMessagePermissionStep);

            // Configuration mode step
            var confirmation = GenerateConfirmation();

            confirmation.NextHandler += () =>
            {
                if (changeManager)
                {
                    configuration.Security = new InternalServerSecurity();
                }
                configuration.Projects[projectSelection.SelectedProject].Security = GeneratePermissions(defaultPermission,
                                                                                                        forceBuildPermission,
                                                                                                        startProjectPermission,
                                                                                                        sendMessagePermission);
                configuration.Security = configuration.Security;    // Force a refresh
                return(true);
            };
            steps.Add(confirmation);
            steps.Add(new TextDisplayStep("Users have been imported", "Finished"));

            var result = controller.StartWizard("Security Configuration Wizard");
        }
        public static User RunNewUserWizard()
        {
            //Create a list of steps
            List <IStep> steps   = new List <IStep>();
            User         newUser = new User();

            //Step 1. Welcome message
            TextBox t = new TextBox();

            t.Multiline  = true;
            t.ScrollBars = ScrollBars.Vertical;
            t.ReadOnly   = true;
            t.Text       = Resources.WelcomeMessage;
            t.Select(0, 0);
            steps.Add(new TemplateStep(t, 10, "Welcome"));

            //Step 2. Role selection
            var roleStep = new TextSelectionStep("Please select the user's role",
                                                 Enum.GetNames(typeof(User.UserRole)))
            {
                Title = "Role Selection"
            };

            roleStep.NextHandler = () =>
            {
                string roleSelectionResult = roleStep.Selected[0];
                newUser.Role = (User.UserRole)Enum.Parse(typeof(User.UserRole), roleSelectionResult);
                return(true);
            };
            steps.Add(roleStep);

            //Step 3. User Permissions
            string permissionCompanyConfidential = "Access &Company Confidential Data";
            string permissionPersonalData        = "Access Other Employees' &Personal Data";
            string permissionEmbezzle            = "Embe&zzle Money From Bank Accounts";

            var permissionStep = new TextSelectionStep("Allow the new user to...",
                                                       permissionCompanyConfidential, permissionPersonalData, permissionEmbezzle)
            {
                Title       = "User Permissions",
                Cardinality = TextSelectionStep.SelectionCardinality.Multiple
            };

            permissionStep.NextHandler = () =>
            {
                newUser.Permissions.CompanyConfidential = permissionStep.Selected.Contains(permissionCompanyConfidential);
                newUser.Permissions.PersonalData        = permissionStep.Selected.Contains(permissionPersonalData);
                newUser.Permissions.Embezzle            = permissionStep.Selected.Contains(permissionEmbezzle);
                return(true);
            };
            steps.Add(permissionStep);

            //Step 4. User Details
            var userFormStep = new TextFormStep("User Details");

            userFormStep.Subtitle = "This step allows you to specify the user's personal information.";
            userFormStep.Prompt   = "Please provide the following user information:";
            var userIdQuestion   = userFormStep.AddQuestion("User &ID:", Validation.NonEmpty);
            var fullNameQuestion = userFormStep.AddQuestion("Full &Name:", Validation.NonEmpty);
            var passwordQuestion = userFormStep.AddQuestion("&Password (6 or more characters):",
                                                            Validation.MinLength(6), '*');
            var passwordQuestionRetype = userFormStep.AddQuestion("&Retype Password:"******"&E-Mail address:", Validation.NonEmpty);

            steps.Add(userFormStep);
            userFormStep.NextHandler = () =>
            {
                if (!passwordQuestion.Answer.Equals(passwordQuestionRetype.Answer))
                {
                    MessageBox.Show("The password does not match the retyped password.",
                                    Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(false);
                }
                newUser.FullName = fullNameQuestion.Answer;
                newUser.Email    = emailAddressQuestion.Answer;
                newUser.Password = passwordQuestion.Answer;
                newUser.UserId   = userIdQuestion.Answer;
                return(true);
            };

            //Step 5. Picture Selection step. This step features the selection of a file.
            var pictureSelectionStep = new FileSelectionStep("User picture selection", "Please provide a picture for this user.");

            pictureSelectionStep.Filter           = "Images|*.bmp;*.jpg;*.gif;*.tif;*.png|All Files (*.*)|*.*";
            pictureSelectionStep.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            pictureSelectionStep.NextHandler      = () =>
            {
                if (File.Exists(pictureSelectionStep.SelectedFullPath))
                {
                    newUser.Picture = Image.FromFile(pictureSelectionStep.SelectedFullPath);
                    return(true);
                }
                else
                {
                    MessageBox.Show("Selected image does not exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(false);
                }
            };
            pictureSelectionStep.AllowNextStrategy =
                () => !string.IsNullOrEmpty(pictureSelectionStep.SelectedFullPath);
            steps.Add(pictureSelectionStep);

            //Step 6. Preview step. This step features a custom UI implemented separately.
            steps.Add(new CustomSteps.PreviewStep(newUser));

            //Run the wizard with the steps defined above
            WizardController wizardController = new WizardController(steps);

            wizardController.LogoImage = Resources.NerlimWizardHeader;
            var wizardResult = wizardController.StartWizard("New User");

            //If the user clicked "Cancel", don't add the user
            if (wizardResult == WizardController.WizardResult.Cancel)
            {
                newUser = null;
            }

            return(newUser);
        }
예제 #4
0
 public void SetupTest()
 {
     _wizardController = new WizardController();
     _step1            = _mock.StrictMock <IWizardStep>();
     _wizardController.AddStep(_step1);
 }
예제 #5
0
 public void TestConstructor()
 {
     _wizardController = new WizardController();
     Assert.That(_wizardController.StepCount == 0);
 }
예제 #6
0
 // Use this for initialization
 void Start()
 {
     wizardController = GetComponent <WizardController>();
     player           = GameObject.FindWithTag("Player");
     InvokeRepeating("ShootToPlayer", 2.0f, 3.0f);
 }
예제 #7
0
    public void Load(string filename)
    {
        Debug.Log("Loading unit");
        FileStream   inFile = new FileStream(filename, FileMode.Open, FileAccess.Read);
        StreamReader reader = new StreamReader(inFile);
        string       recordIn;

        recordIn = reader.ReadLine();
        while (recordIn != null)
        {
            string[] info   = recordIn.Split(' ');
            int      length = recordIn.IndexOf(" ");

            string firstField = recordIn.Substring(0, length);

            switch (firstField)
            {
            case "FactoryBuildingA":
                GameObject newBuildingA = Instantiate(FactoryBuildingA) as GameObject;
                newBuildingA.transform.position = new Vector3(float.Parse(info[1]), float.Parse(info[2]), float.Parse(info[3]));
                BuildingInfo buildingInfoA = newBuildingA.GetComponent <BuildingInfo>();
                buildingInfoA.Health = int.Parse(info[4]);
                break;

            case "FactoryBuildingB":
                GameObject newBuildingB = Instantiate(FactoryBuildingB) as GameObject;
                newBuildingB.transform.position = new Vector3(float.Parse(info[1]), float.Parse(info[2]), float.Parse(info[3]));
                BuildingInfo buildingInfoB = newBuildingB.GetComponent <BuildingInfo>();
                buildingInfoB.Health = int.Parse(info[4]);
                break;

            case "Building":
                GameObject newBuildingW = Instantiate(WizardBuilding) as GameObject;
                newBuildingW.transform.position = new Vector3(float.Parse(info[2]), float.Parse(info[3]), float.Parse(info[4]));
                SpawnWizard buildingInfoW = newBuildingW.GetComponent <SpawnWizard>();
                buildingInfoW.UnitAmount = 10;
                break;

            case "rbA":
                GameObject newBuildingrbA = Instantiate(ResourceBuildingA) as GameObject;
                ResourceBuildingA.transform.position = new Vector3(float.Parse(info[3]), float.Parse(info[4]), float.Parse(info[5]));
                BuildingInfo buildingInfoRbA = newBuildingrbA.GetComponent <BuildingInfo>();
                buildingInfoRbA.Health = int.Parse(info[6]);
                ResourceManagement resourceInfoA = ResourceBuildingA.GetComponent <ResourceManagement>();
                resourceInfoA.ResourceTotal      = int.Parse(info[1]);
                resourceInfoA.ResourcesGenerated = int.Parse(info[2]);
                break;

            case "rbB":
                GameObject newBuildingrbB = Instantiate(ResourceBuildingB) as GameObject;
                ResourceBuildingB.transform.position = new Vector3(float.Parse(info[3]), float.Parse(info[4]), float.Parse(info[5]));
                BuildingInfo buildingInfoRbB = newBuildingrbB.GetComponent <BuildingInfo>();
                buildingInfoRbB.Health = int.Parse(info[6]);
                ResourceManagement resourceInfoB = ResourceBuildingB.GetComponent <ResourceManagement>();
                resourceInfoB.ResourceTotal      = int.Parse(info[1]);
                resourceInfoB.ResourcesGenerated = int.Parse(info[2]);
                break;

            case "TeamA":
                if (info[2] == "400")
                {
                    GameObject teamAMeleeUnit = Instantiate(TeamAMeleeUnit) as GameObject;
                    teamAMeleeUnit.transform.position = new Vector3(float.Parse(info[3]), float.Parse(info[4]), float.Parse(info[5]));
                    UnitAController teamAMeleeUnitInfo = teamAMeleeUnit.GetComponent <UnitAController>();
                    teamAMeleeUnitInfo.Health   = int.Parse(info[1]);
                    teamAMeleeUnitInfo.UnitType = "Melee";
                }
                else
                {
                    GameObject teamARangedUnit = Instantiate(TeamARangedUnit) as GameObject;
                    teamARangedUnit.transform.position = new Vector3(float.Parse(info[3]), float.Parse(info[4]), float.Parse(info[5]));
                    UnitAController teamARangedUnitInfo = teamARangedUnit.GetComponent <UnitAController>();
                    teamARangedUnitInfo.Health   = int.Parse(info[1]);
                    teamARangedUnitInfo.UnitType = "Ranged";
                }
                break;

            case "TeamB":
                if (info[2] == "400")
                {
                    GameObject teamBMeleeUnit = Instantiate(TeamBMeleeUnit) as GameObject;
                    teamBMeleeUnit.transform.position = new Vector3(float.Parse(info[3]), float.Parse(info[4]), float.Parse(info[5]));
                    UnitAController teamBMeleeUnitInfo = teamBMeleeUnit.GetComponent <UnitAController>();
                    teamBMeleeUnitInfo.Health   = int.Parse(info[1]);
                    teamBMeleeUnitInfo.UnitType = "Melee";
                }
                else
                {
                    GameObject teamBRangedUnit = Instantiate(TeamBRangedUnit) as GameObject;
                    teamBRangedUnit.transform.position = new Vector3(float.Parse(info[3]), float.Parse(info[4]), float.Parse(info[5]));
                    UnitAController teamBRangedUnitInfo = teamBRangedUnit.GetComponent <UnitAController>();
                    teamBRangedUnitInfo.Health   = int.Parse(info[1]);
                    teamBRangedUnitInfo.UnitType = "Ranged";
                }
                break;

            case "Wizard":
                Debug.Log("Wizard Spawn");
                GameObject wizard = Instantiate(WizardUnit) as GameObject;
                wizard.transform.position = new Vector3(float.Parse(info[2]), float.Parse(info[3]), float.Parse(info[4]));
                WizardController wizardInfo = wizard.GetComponent <WizardController>();
                wizardInfo.Health = int.Parse(info[1]);
                break;
            }
            recordIn = reader.ReadLine();
        }
        reader.Close();
        inFile.Close();
    }
예제 #8
0
 // Use this for initialization
 void Start()
 {
     wizard    = (WizardController)GameObject.Find("Wizard").GetComponent("WizardController");
     maxHealth = WizardController.MAX_HEALTH;
 }
예제 #9
0
 public void SetController(WizardController controller)
 {
     this.wizardController = controller;
 }
예제 #10
0
 // Use this for initialization
 void Start()
 {
     wizardController = GetComponent <WizardController>();
 }
예제 #11
0
 private void Awake()
 {
     Instance = this;
 }
예제 #12
0
        public WeblogConfigurationWizardPanelGoogleBloggerAuthentication(string blogId, WizardController wizardController)
        {
            _blogId           = blogId;
            _wizardController = wizardController;

            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            labelHeader.Text      = Res.Get(StringId.CWGoogleBloggerTitle);
            labelDescription.Text = Res.Get(StringId.CWGoogleBloggerDescription);
            buttonLogin.Text      = Res.Get(StringId.Login);
        }