示例#1
0
 public void TheGraphIsReady()
 {
     thisPursuerInstance = GetComponent <Pursuer>();
     targetOldPos        = target.transform.position;
     thisPursuerInstance.MoveTo(target.transform);
     isReady = true;
 }
示例#2
0
 private void Start()
 {
     /*traceToggle = GameObject.Find("drawToggle").GetComponent<Toggle>();
      * optimizeToggle = GameObject.Find("optimizeToggle").GetComponent<Toggle>();
      * smoothToggle = GameObject.Find("smoothToggle").GetComponent<Toggle>();*/
     thisPursuerInstance = gameObject.GetComponent <Pursuer>();
 }
        private void recalculatingPersuersDirections()
        {
            List <double> Times = new List <double>(); // времена до поимки, если по одиночке

            // Пересчет управления преследователей
            for (int i = 0; i < game.pursuers.Count; i++)
            {
                var evaderX  = game.evader.v.X;
                var evaderY  = game.evader.v.Y;
                var persuerX = game.pursuers[i].Z.X;
                var persuerY = game.pursuers[i].Z.Y;

                var lambda = game.Calc_lambda(evaderX, evaderY, persuerX, persuerY, game.time, game.A, game.U, game.pursuers[i].capture);

                game.pursuers[i].setl(lambda);
                game.pursuers[i].Calc_TimeBeforeCapture(game.evader.coordinates.X, game.evader.coordinates.Y);

                if (game.pursuers[i].TimeBeforeCapture > 0)
                {
                    Times.Add(game.pursuers[i].TimeBeforeCapture);
                }
            }
            Pursuer.Calc_TimeBeforeSynchronousCapture(Times, game.M);
            for (int i = 0; i < game.pursuers.Count; i++)
            {
                game.pursuers[i].Calc_u1_u2(game.evader.v.X, game.evader.v.Y, game.A, game.U, game);
            }
        }
示例#4
0
    // Update is called once per frame
    void Update()
    {
        if (!isSceneReady)
        {
            isSceneReady = spaceManagerInstance.isPrimaryProcessingCompleted;
        }

        if (isSceneReady && canSpawn)
        {
            float y = Random.Range(15, 140);
            transform.position = new Vector3(transform.position.x, y, transform.position.z);
            GameObject spawnedEnemy = Instantiate(enemyPrefab, transform.position, Quaternion.identity);
            /*GameObject.Find("defender").GetComponent<DefenderController>().enemyDict.Add(spawnedEnemy.transform,false);*/
            Pursuer spawnedPursuerInstance = spawnedEnemy.GetComponent <Pursuer>();
            spawnedPursuerInstance.trajectoryOptimization = optimizeTrajectory;
            spawnedPursuerInstance.trajectorySmoothing    = smoothTrajectory;
            spawnedPursuerInstance.tracePath = drawTrajectory;
            spawnedPursuerInstance.MoveTo(target);
            spawnedEnemy.transform.rotation = Quaternion.LookRotation(target.position - spawnedEnemy.transform.position);
            /*spawnedPursuerInstance.yMax = y +  15;*/
            /*spawnedPursuerInstance.speed = Random.Range(.15f,.5f);*/
            canSpawn = false;
            StartCoroutine(SpawnAllower());
        }
    }
示例#5
0
        public void Init(Transform target, EnemyMovementSetting settings)
        {
            _target = target;

            switch (settings.movementType)
            {
            case EnemyMovementType.GROUND:
                NavMeshAgent agent = gameObject.AddComponent <NavMeshAgent>();
                _movementBehaviour = new NavMeshMovement(agent, settings.speed, settings.stoppingDistance);
                break;

            case EnemyMovementType.FLYING:
                Pursuer pursuer = gameObject.AddComponent <Pursuer>();
                pursuer.SetConstraints(settings.xMin, settings.xMax, settings.yMin, settings.yMax, settings.zMin,
                                       settings.zMax);
                pursuer.SetPathfindingParameters(settings.selectedPFAlg, settings.pathfindingLevel,
                                                 settings.inEditorPathfindingTraverce, settings.heuristicFactor, settings.trajectoryOptimization,
                                                 settings.trajectorySmoothing);
                pursuer.SetMovementSettings(settings.speed, settings.moveVectorOrientation, settings.turnSpeed);
                _movementBehaviour = new FlyingMovement(pursuer, settings.lesion, settings.updateOffset);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#6
0
 //Start pursuit of the target
 public void BeginPursuit(GameObject target)
 {
     this.target            = target.transform;
     thisPursuerInstance    = GetComponent <Pursuer>();
     targetOldPos           = target.transform.position;
     targetPathUpdateOffset = 8;
     thisPursuerInstance.MoveTo(target.transform);
 }
示例#7
0
 private void Start()
 {
     lineContainer      = new GameObject();
     lineContainer.name = "spline";
     line                 = lineContainer.AddComponent <LineRenderer>();
     line.material        = lineMaterial;
     line.loop            = false;
     thisPursuerInstance  = GetComponent <Pursuer>();
     spaceManagerinstance = Component.FindObjectOfType <SpaceManager>();
     trajectory           = new List <Vector3>();
     toOldPos             = toPoint.position;
     fromOldPos           = transform.position;
 }
示例#8
0
        /// <summary>
        /// makes sure the active param object matches the GUI
        /// </summary>
        private void setParamData()
        {
            //param.canEvadersReceiveMultipleBroadcasts = chkMultipleBroadcasts.Checked;
            //param.canSinksSensePursuers = chkSinksSensePursuers.Checked;
            //param.areSinksSafe = chkSafeSinks.Checked;

            int psi;

            if (tryParseTextBox(txtPursuerCount, lblPursuerCount, out psi))
            {
                param.A_P = Pursuer.getAgents(psi);
            }

            int evaderCount;

            if (tryParseTextBox(txtEvadersCount, lblEvaderCount, out evaderCount))
            {
                param.A_E = Evader.getAgents(evaderCount);
            }

            int res;

            if (tryParseTextBox(txtres, lblrs, out res))
            {
                param.r_e = res;
            }

            float fe;

            if (tryParseTextBox(txtRenewal, lblREnewal, out fe))
            {
                param.f_e = fe;
            }

            float dp;

            if (tryParseTextBox(txtDetectionProb, lblDetectionProb, out dp))
            {
                param.detectionProbRestraint = dp;
            }
        }
示例#9
0
        public static void eraseAllRoles(this PlayerControl player)
        {
            foreach (var t in RoleData.allRoleTypes)
            {
                t.Value.GetMethod("eraseRole", BindingFlags.Public | BindingFlags.Static)?.Invoke(null, new object[] { player });
            }

            // Crewmate roles
            if (player.isRole(RoleType.Mayor))
            {
                Mayor.clearAndReload();
            }
            if (player.isRole(RoleType.Engineer))
            {
                Engineer.clearAndReload();
            }
            if (player.isRole(RoleType.Detective))
            {
                Detective.clearAndReload();
            }
            if (player.isRole(RoleType.TimeMaster))
            {
                TimeMaster.clearAndReload();
            }
            if (player.isRole(RoleType.Medic))
            {
                Medic.clearAndReload();
            }
            if (player.isRole(RoleType.Shifter))
            {
                Shifter.clearAndReload();
            }
            if (player.isRole(RoleType.Seer))
            {
                Seer.clearAndReload();
            }
            if (player.isRole(RoleType.Hacker))
            {
                Hacker.clearAndReload();
            }
            if (player.isRole(RoleType.Tracker))
            {
                Tracker.clearAndReload();
            }
            if (player.isRole(RoleType.Snitch))
            {
                Snitch.clearAndReload();
            }
            if (player.isRole(RoleType.Swapper))
            {
                Swapper.clearAndReload();
            }
            if (player.isRole(RoleType.Spy))
            {
                Spy.clearAndReload();
            }
            if (player.isRole(RoleType.SecurityGuard))
            {
                SecurityGuard.clearAndReload();
            }
            if (player.isRole(RoleType.Bait))
            {
                Bait.clearAndReload();
            }
            if (player.isRole(RoleType.Medium))
            {
                Medium.clearAndReload();
            }

            // Impostor roles
            if (player.isRole(RoleType.Morphling))
            {
                Morphling.clearAndReload();
            }
            if (player.isRole(RoleType.Camouflager))
            {
                Camouflager.clearAndReload();
            }
            if (player.isRole(RoleType.Godfather))
            {
                Godfather.clearAndReload();
            }
            if (player.isRole(RoleType.Mafioso))
            {
                Mafioso.clearAndReload();
            }
            if (player.isRole(RoleType.Janitor))
            {
                Janitor.clearAndReload();
            }
            if (player.isRole(RoleType.Vampire))
            {
                Vampire.clearAndReload();
            }
            if (player.isRole(RoleType.Eraser))
            {
                Eraser.clearAndReload();
            }
            if (player.isRole(RoleType.Trickster))
            {
                Trickster.clearAndReload();
            }
            if (player.isRole(RoleType.Cleaner))
            {
                Cleaner.clearAndReload();
            }
            if (player.isRole(RoleType.Warlock))
            {
                Warlock.clearAndReload();
            }
            if (player.isRole(RoleType.Witch))
            {
                Witch.clearAndReload();
            }
            if (player.isRole(RoleType.Assassin))
            {
                Assassin.clearAndReload();
            }
            if (player.isRole(RoleType.EvilHacker))
            {
                EvilHacker.clearAndReload();
            }

            // Other roles
            if (player.isRole(RoleType.Jester))
            {
                Jester.clearAndReload();
            }
            if (player.isRole(RoleType.Arsonist))
            {
                Arsonist.clearAndReload();
            }
            if (player.isRole(RoleType.Sidekick))
            {
                Sidekick.clearAndReload();
            }
            if (player.isRole(RoleType.BountyHunter))
            {
                BountyHunter.clearAndReload();
            }
            if (player.isRole(RoleType.Vulture))
            {
                Vulture.clearAndReload();
            }
            if (player.isRole(RoleType.Lawyer))
            {
                Lawyer.clearAndReload();
            }
            if (player.isRole(RoleType.Pursuer))
            {
                Pursuer.clearAndReload();
            }
            if (Guesser.isGuesser(player.PlayerId))
            {
                Guesser.clear(player.PlayerId);
            }


            if (player.isRole(RoleType.Jackal))
            { // Promote Sidekick and hence override the the Jackal or erase Jackal
                if (Sidekick.promotesToJackal && Sidekick.sidekick != null && Sidekick.sidekick.isAlive())
                {
                    RPCProcedure.sidekickPromotes();
                }
                else
                {
                    Jackal.clearAndReload();
                }
            }
        }
示例#10
0
 private void Start()
 {
     pursuerInstance = plane.GetComponent <Pursuer>();
     pursuerInstance.MoveTo(target.position);
 }
示例#11
0
 public FlyingMovement(Pursuer pursuer, float lesion, float updateOffset)
 {
     _pursuer = pursuer;
     _targetLesionAreaRadius = lesion;
     _targetPathUpdateOffset = updateOffset;
 }
示例#12
0
 private void Start()
 {
     targetOldPos    = Vector3.zero;
     pursuerInstance = gameObject.GetComponent <Pursuer>();
 }
示例#13
0
        /// <summary>
        /// makes sure the active param object matches the GUI
        /// </summary>
        private void setParamData()
        {
            //param.canEvadersReceiveMultipleBroadcasts = chkMultipleBroadcasts.Checked;
            //param.canSinksSensePursuers = chkSinksSensePursuers.Checked;
            //param.areSinksSafe = chkSafeSinks.Checked;

            int psi;

            if (tryParseTextBox(txtPursuerCount, lblPursuerCount, out psi))
            {
                param.A_P = Pursuer.getAgents(psi);
            }

            int evaderCount;

            if (tryParseTextBox(txtEvadersCount, lblEvaderCount, out evaderCount))
            {
                param.A_E = Evader.getAgents(evaderCount);
            }

            int rp;

            if (tryParseTextBox(txtrp, lblrp, out rp))
            {
                param.r_p = rp;
            }

            int re;

            // if area is square, also make sure re is valid i.e. odd value
            if (tryParseTextBox(txtre, lblre, out re, (reval) => { return(!chkSquareArea.Checked || reval % 2 == 1); }))
            {
                param.r_e = re;
            }


            int res;

            if (tryParseTextBox(txtres, lblrs, out res))
            {
                param.r_es = res;
            }

            //int rps;
            //if (tryParseTextBox(txtrps, lblrs, out rps))
            //    param.r_ps = rps;

            int ti;

            if (tryParseTextBox(txtti, lblti, out ti))
            {
                param.t_i = ti;
            }


            param.IsAreaSquare = chkSquareArea.Checked;

            //try
            //{
            //    // set reward func:
            //    if (cmbRewardFunc.SelectedItem == null)
            //    {
            //        lblR.ForeColor = Color.Red;
            //        return;
            //    }

            //    param.R = ReflectionUtils.constructEmptyCtorType<ARewardFunction>((string)cmbRewardFunc.SelectedItem);
            //    lblR.ForeColor = Color.Black;
            //    lstRewarrdDesc.Items.Clear();
            //    lstRewarrdDesc.Items.AddRange(param.R.argumentsDescription().ToArray<object>());

            //    try
            //    {
            //        param.R.setArgs(txtRewardArg.Text);
            //        lblRewardArg.ForeColor = Color.Black;
            //    }
            //    catch (Exception)
            //    {
            //        lblRewardArg.ForeColor = Color.Red;
            //    }

            //}
            //catch (Exception ex)
            //{
            //    lblR.ForeColor = Color.Red;
            //}
        }
示例#14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            foreach (object o in this.Controls)
            {
                Label l = o as Label;

                if (l != null && l.ForeColor.ToArgb() != Color.Black.ToArgb() && l.Visible == true)     // ensure all fields are "valid"
                {
                    MessageBox.Show(l.Text + " has invalid value");
                    return;
                }
            }
            SaveFileDialog d = new SaveFileDialog();

            d.Filter = "Intrusion Game Param Files (*." + AppConstants.FileExtensions.INTRUSION_PARAM + ")|*." + AppConstants.FileExtensions.INTRUSION_PARAM;

            try
            {
                if (d.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                string dialogFilename = d.FileName;

                int minTI  = Int32.Parse(txtti.Text);
                int minRES = Int32.Parse(txtres.Text);
                //int minRPS = Int32.Parse(txtrps.Text);
                int minRP  = Int32.Parse(txtrp.Text);
                int minPsi = Int32.Parse(txtPursuerCount.Text);
                int minEta = Int32.Parse(txtEvadersCount.Text);
                //string minRewardArg = txtRewardArg.Text;

                int maxRP  = minRP;
                int maxPsi = minPsi;
                int maxEta = minEta;
                int maxRES = minRES;
                //int maxRPS = minRPS;
                int maxTI = minTI;

                //string maxRewardArg = txtRewardArgMax.Text;

                if (txtMaxRP.Text.Length > 0)
                {
                    Int32.TryParse(txtMaxRP.Text, out maxRP);
                }
                if (txtMaxPsi.Text.Length > 0)
                {
                    Int32.TryParse(txtMaxPsi.Text, out maxPsi);
                }
                if (txtMaxEta.Text.Length > 0)
                {
                    Int32.TryParse(txtMaxEta.Text, out maxEta);
                }
                if (txtMaxRes.Text.Length > 0)
                {
                    Int32.TryParse(txtMaxRes.Text, out maxRES);
                }
                //if (txtMaxRps.Text.Length > 0)
                //     Int32.TryParse(txtMaxRps.Text, out maxRPS);
                if (txtMaxTi.Text.Length > 0)
                {
                    Int32.TryParse(txtMaxTi.Text, out maxTI);
                }

                if (maxRP == minRP && maxPsi == minPsi && maxEta == minEta
                    //&& maxRPS == minRPS
                    && maxRES == minRES && minTI == maxTI /*&& maxRewardArg.Length == 0*/)
                {
                    param.serialize(d.FileName);
                }
                else
                {
                    //string rewardJump = txtRewardArgJump.Text;
                    int rpJump = 0, psiJump = 0, etaJump = 0, resJump = 0, rpsJump = 0, tiJump;
                    Int32.TryParse(txtPsiJump.Text, out psiJump);
                    Int32.TryParse(txtEtaJump.Text, out etaJump);
                    Int32.TryParse(txtRPJump.Text, out rpJump);
                    Int32.TryParse(txtResJump.Text, out resJump);
                    //Int32.TryParse(txtRpsJump.Text, out rpsJump);
                    Int32.TryParse(txtTiJump.Text, out tiJump);

                    rpJump  = Math.Max(rpJump, 1);
                    psiJump = Math.Max(psiJump, 1);
                    etaJump = Math.Max(etaJump, 1);
                    resJump = Math.Max(resJump, 1);
                    //rpsJump = Math.Max(rpsJump, 1);
                    tiJump = Math.Max(tiJump, 1);

                    dialogFilename = dialogFilename.Substring(0, dialogFilename.LastIndexOf('.'));

                    string newFolderName = "";

                    try
                    {
                        char slash = '\\';
                        if (!dialogFilename.Contains(slash))
                        {
                            slash = '/';
                        }

                        newFolderName = dialogFilename.Substring(dialogFilename.LastIndexOf(slash) + 1);
                        Directory.CreateDirectory(dialogFilename);
                        dialogFilename += (slash + newFolderName);
                    }
                    catch (Exception) { }

                    //var rewardFuncs = param.R.getRewardFunctions(minRewardArg, maxRewardArg, rewardJump);

                    //foreach(ARewardFunction rw in rewardFuncs)
                    //for (int rps = minRPS; rps <= maxRPS; rps += rpsJump)
                    for (int res = minRES; res <= maxRES; res += resJump)
                    {
                        for (int rp = minRP; rp <= maxRP; rp += rpJump)
                        {
                            for (int psi = minPsi; psi <= maxPsi; psi += psiJump)
                            {
                                for (int eta = minEta; eta <= maxEta; eta += etaJump)
                                {
                                    for (int ti = minTI; ti <= maxTI; ti += tiJump)
                                    {
                                        param.A_E  = Evader.getAgents(eta);
                                        param.A_P  = Pursuer.getAgents(psi);
                                        param.r_p  = rp;
                                        param.t_i  = ti;
                                        param.r_es = res;
                                        //param.r_ps = rps;

                                        //param.R = rw;


                                        string fileName =
                                            dialogFilename + "_eta" + eta.ToString() +
                                            "_rp" + rp.ToString() +
                                            "_psi" + psi.ToString() +
                                            "_res" + res.ToString() +
                                            //"_rps" + rps.ToString() +
                                            "_ti" + ti.ToString() +
                                            //"_" + rw.fileNameDescription() +
                                            "." + AppConstants.FileExtensions.INTRUSION_PARAM;
                                        param.serialize(fileName);
                                    }
                                }
                            }
                        }
                    }
                }

                isDirty       = false;
                ParamFilePath = d.FileName;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#15
0
 void Start()
 {
     pursuerInstance = pathfinder.GetComponent <Pursuer>();
 }
示例#16
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            foreach (object o in this.Controls)
            {
                Label l = o as Label;

                if (l != null && l.ForeColor.ToArgb() != Color.Black.ToArgb() && l.Visible == true)     // ensure all fields are "valid"
                {
                    MessageBox.Show(l.Text + " has invalid value");
                    return;
                }
            }
            SaveFileDialog d = new SaveFileDialog();

            d.Filter = "Routing Game Param Files (*." + AppConstants.FileExtensions.ROUTING_PARAM + ")|*." + AppConstants.FileExtensions.ROUTING_PARAM;

            try
            {
                if (d.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                string dialogFilename = d.FileName;


                float minRenew = float.Parse(txtRenewal.Text);
                int   minRES   = Int32.Parse(txtres.Text);
                //int minRPS = Int32.Parse(txtrps.Text);

                int minPsi = Int32.Parse(txtPursuerCount.Text);
                int minEta = Int32.Parse(txtEvadersCount.Text);
                //string minRewardArg = txtRewardArg.Text;


                int maxPsi = minPsi;
                int maxEta = minEta;
                int maxRES = minRES;
                //int maxRPS = minRPS;
                float maxRenew = minRenew;

                //string maxRewardArg = txtRewardArgMax.Text;


                if (txtMaxPsi.Text.Length > 0)
                {
                    Int32.TryParse(txtMaxPsi.Text, out maxPsi);
                }
                if (txtMaxEta.Text.Length > 0)
                {
                    Int32.TryParse(txtMaxEta.Text, out maxEta);
                }
                if (txtMaxRes.Text.Length > 0)
                {
                    Int32.TryParse(txtMaxRes.Text, out maxRES);
                }
                //if (txtMaxRps.Text.Length > 0)
                //     Int32.TryParse(txtMaxRps.Text, out maxRPS);
                if (txtRenewalMax.Text.Length > 0)
                {
                    float.TryParse(txtRenewalMax.Text, out maxRenew);
                }

                if (minRenew == maxRenew && maxPsi == minPsi && maxEta == minEta && maxRES == minRES)
                {
                    param.serialize(d.FileName);
                }
                else
                {
                    //string rewardJump = txtRewardArgJump.Text;
                    int   rpJump, psiJump, etaJump, resJump, rpsJump;
                    float renewalJump;
                    Int32.TryParse(txtPsiJump.Text, out psiJump);
                    Int32.TryParse(txtEtaJump.Text, out etaJump);
                    Int32.TryParse(txtResJump.Text, out resJump);
                    float.TryParse(txtRenewalJump.Text, out renewalJump);


                    psiJump     = Math.Max(psiJump, 1);
                    etaJump     = Math.Max(etaJump, 1);
                    resJump     = Math.Max(resJump, 1);
                    renewalJump = Math.Max(renewalJump, 0);

                    dialogFilename = dialogFilename.Substring(0, dialogFilename.LastIndexOf('.'));

                    string newFolderName = "";

                    try
                    {
                        char slash = '\\';
                        if (!dialogFilename.Contains(slash))
                        {
                            slash = '/';
                        }

                        newFolderName = dialogFilename.Substring(dialogFilename.LastIndexOf(slash) + 1);
                        Directory.CreateDirectory(dialogFilename);
                        dialogFilename += (slash + newFolderName);
                    }
                    catch (Exception) { }

                    //var rewardFuncs = param.R.getRewardFunctions(minRewardArg, maxRewardArg, rewardJump);

                    //foreach(ARewardFunction rw in rewardFuncs)
                    //for (int rps = minRPS; rps <= maxRPS; rps += rpsJump)
                    for (int res = minRES; res <= maxRES; res += resJump)
                    {
                        for (int psi = minPsi; psi <= maxPsi; psi += psiJump)
                        {
                            for (int eta = minEta; eta <= maxEta; eta += etaJump)
                            {
                                for (float renewal = minRenew; renewal <= maxRenew; renewal += renewalJump)
                                {
                                    param.A_E = Evader.getAgents(eta);
                                    param.A_P = Pursuer.getAgents(psi);
                                    param.r_e = res;
                                    param.detectionProbRestraint = double.Parse(txtDetectionProb.Text);
                                    param.f_e = renewal;
                                    //param.r_ps = rps;

                                    //param.R = rw;


                                    string fileName =
                                        dialogFilename + "_eta" + eta.ToString() +
                                        "_psi" + psi.ToString() +
                                        "_res" + res.ToString() +
                                        "_fe" + renewal.ToString("0.00") +
                                        "." + AppConstants.FileExtensions.ROUTING_PARAM;
                                    param.serialize(fileName);
                                }
                            }
                        }
                    }
                }

                isDirty       = false;
                ParamFilePath = d.FileName;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#17
0
    public override void OnInspectorGUI()
    {
//        base.OnInspectorGUI();
        pursuerClassInst = (Pursuer)target;

        EditorGUILayout.BeginVertical();
        EditorGUILayout.LabelField("Game zone constraints:", EditorStyles.boldLabel);
        EditorGUILayout.BeginHorizontal();
        _xMin.floatValue = EditorGUILayout.FloatField("XMin & XMax: ", _xMin.floatValue);
        _xMax.floatValue = EditorGUILayout.FloatField(_xMax.floatValue);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        _yMin.floatValue = EditorGUILayout.FloatField("YMin & YMax: ", _yMin.floatValue);
        _yMax.floatValue = EditorGUILayout.FloatField(_yMax.floatValue);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        _zMin.floatValue = EditorGUILayout.FloatField("ZMin & ZMax: ", _zMin.floatValue);
        _zMax.floatValue = EditorGUILayout.FloatField(_zMax.floatValue);
        EditorGUILayout.EndHorizontal();



        EditorGUILayout.LabelField("Pathfinding settings:", EditorStyles.boldLabel);
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Pathfinding algorithm:");
        Pursuer.PathfindingAlgorithm newEnum = (Pursuer.PathfindingAlgorithm)_selectedPFAlg.enumValueIndex;
        newEnum = (Pursuer.PathfindingAlgorithm)EditorGUILayout.EnumPopup(newEnum);
        _selectedPFAlg.enumValueIndex = (int)newEnum;
        EditorGUILayout.EndHorizontal();
        if (pursuerClassInst.selectedPFAlg == Pursuer.PathfindingAlgorithm.AStar)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Heuristic factor:");
            _heuristicFactor.floatValue = EditorGUILayout.Slider(_heuristicFactor.floatValue, .5f, 1f);
            EditorGUILayout.EndHorizontal();
        }
        else
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("In-editor pathfinding traverce:");
            _inEditorPathfindingTraverce.boolValue = EditorGUILayout.Toggle(_inEditorPathfindingTraverce.boolValue);
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Number of pathfinding level: ", EditorStyles.wordWrappedLabel);
        SpaceManager sMInst = Component.FindObjectOfType <SpaceManager>();

        if (sMInst != null)
        {
            _pathfindingLevel.intValue =
                EditorGUILayout.IntSlider(pursuerClassInst.pathfindingLevel, 0, sMInst.gridDetailLevelsCount - 1);
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Trajectory optimization:");
        _trajectoryOptimization.boolValue = EditorGUILayout.Toggle(_trajectoryOptimization.boolValue);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Trajectory smoothing:");
        _trajectorySmoothing.boolValue = EditorGUILayout.Toggle(_trajectorySmoothing.boolValue);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.LabelField("Movement settings:", EditorStyles.boldLabel);
        _speed.floatValue = Mathf.Max(EditorGUILayout.FloatField("Speed:", _speed.floatValue), float.Epsilon);
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Turn in the dir. of movement:");
        _moveVectorOrientation.boolValue = EditorGUILayout.Toggle(_moveVectorOrientation.boolValue);
        EditorGUILayout.EndHorizontal();
        if (_moveVectorOrientation.boolValue)
        {
            _turnSpeed.floatValue = Mathf.Max(EditorGUILayout.FloatField("Turn speed:", _turnSpeed.floatValue),
                                              float.Epsilon);
        }

        EditorGUILayout.LabelField("Other settings:", EditorStyles.boldLabel);
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Generate event messages:");
        _generateEventMessages.boolValue = EditorGUILayout.Toggle(_generateEventMessages.boolValue);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Generate condition messages:");
        _generateCondMessages.boolValue = EditorGUILayout.Toggle(_generateCondMessages.boolValue);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.LabelField("Debug settings:", EditorStyles.boldLabel);
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("In-game trajectory trace:");
        _tracePath.boolValue = EditorGUILayout.Toggle(_tracePath.boolValue);
        EditorGUILayout.EndHorizontal();
        if (_tracePath.boolValue)
        {
            _lineWidth.floatValue = Mathf.Max(EditorGUILayout.FloatField("Line width:", _lineWidth.floatValue), .1f);
            _lineMaterial.objectReferenceValue = (Material)EditorGUILayout.ObjectField("Line material:",
                                                                                       (Material)(_lineMaterial.objectReferenceValue), typeof(Material), true);
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Show pathfinding area in the editor:");
        _showPathfindingZone.boolValue = EditorGUILayout.Toggle(_showPathfindingZone.boolValue);
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.EndVertical();
        serializedObject.ApplyModifiedProperties();
    }
示例#18
0
        /// <summary>
        /// makes sure the active param object matches the GUI
        /// </summary>
        private void setParamData()
        {
            param.canEvadersReceiveMultipleBroadcasts = chkMultipleBroadcasts.Checked;
            param.canSinksSensePursuers = chkSinksSensePursuers.Checked;
            param.areSinksSafe          = chkSafeSinks.Checked;

            int psi;

            if (tryParseTextBox(txtPursuerCount, lblPursuerCount, out psi))
            {
                param.A_P = Pursuer.getAgents(psi);
            }

            int evaderCount;

            if (tryParseTextBox(txtEvadersCount, lblEvaderCount, out evaderCount))
            {
                param.A_E = Evader.getAgents(evaderCount);
            }

            int rp;

            if (tryParseTextBox(txtrp, lblrp, out rp))
            {
                param.r_p = rp;
            }

            int re;

            if (tryParseTextBox(txtre, lblre, out re))
            {
                param.r_e = re;
            }

            int rs;

            if (tryParseTextBox(txtrs, lblrs, out rs))
            {
                param.r_s = rs;
            }

            float pd;

            if (tryParseTextBox(txtpd, lblpd, out pd))
            {
                param.p_d = pd;
            }

            try
            {
                // set reward func:
                if (cmbRewardFunc.SelectedItem == null)
                {
                    lblR.ForeColor = Color.Red;
                    return;
                }

                param.R        = ReflectionUtils.constructEmptyCtorType <ARewardFunction>((string)cmbRewardFunc.SelectedItem);
                lblR.ForeColor = Color.Black;
                lstRewarrdDesc.Items.Clear();
                lstRewarrdDesc.Items.AddRange(param.R.argumentsDescription().ToArray <object>());

                try
                {
                    param.R.setArgs(txtRewardArg.Text);
                    lblRewardArg.ForeColor = Color.Black;
                }
                catch (Exception)
                {
                    lblRewardArg.ForeColor = Color.Red;
                }

                //// if reward func isn't undefined, check argument validity:
                //int givenArgs;
                //if (txtRewardArg.Text == "")
                //    givenArgs = 0;
                //else
                //    givenArgs = txtRewardArg.Text.Split(new char[] { ',' }).Count() + 1;

                //if (givenArgs == param.R.argumentsDescription().Count)
                //    lblRewardArg.ForeColor = Color.Black;
                //else
                //    lblRewardArg.ForeColor = Color.Red;
            }
            catch (Exception ex)
            {
                lblR.ForeColor = Color.Red;
            }
        }
示例#19
0
 // Start is called before the first frame update
 void Start()
 {
     myPursuer    = this.GetComponent <Pursuer>();
     myFollowPath = this.GetComponent <PathFollower>();
     player       = GameObject.FindGameObjectWithTag("Player");
 }
示例#20
0
 public override void PursuerCollisionEnter(Pursuer pursuer)
 {
     pursuer.HitNotWalkable();
 }