示例#1
0
文件: Entity.cs 项目: konlil/pipe
 public virtual void ApplyEnvInfo(EnvInfo info)
 {
     foreach(RenderContext rc in render_contexts)
     {
         rc.Material.SetEnvInfo(info);
     }
 }
示例#2
0
        protected void OpenInformation()
        {
            System.Diagnostics.Debug.WriteLine("call information");
            using (var infoView = new InformationViewModel())
            {
                Messenger.Raise(new TransitionMessage(infoView, "InformationCommand"));
                this.isLicenseActivate = infoView.IsLicenceActivate;                                   // license が正常に認識されれば true

                System.Diagnostics.Debug.WriteLine("retuen license is " + infoView.IsLicenceActivate); // open URL or PDF
                // ライセンス認証が通って居ればそのまま。
                if (this.isLicenseActivate)
                {
                    return;
                }

                // ライセンス認証通ってなければ再検査。
                if (EnvInfo.IsLicenceInvalid())// license invalid
                {
                    MessageBox.Show("License error. " + Environment.NewLine +
                                    "License is invalid!");
                    System.Threading.Thread.Sleep(1800);
                    Application.Current.Shutdown();
                }
            };

            /*
             * if (ShowConfirmDialog("your address : " + Utils.EnvInfo.firstAddress + Environment.NewLine +
             *                              "contact us? (open web page)", "information") ) {
             *
             *  Utils.Approbate.OpenUrl("https://www.w-fusion.co.jp/J/contactus.php");
             *  System.Diagnostics.Debug.WriteLine("information click."); // open URL or PDF
             * }
             */
        }
示例#3
0
        public void CallAcceptLicense()
        {
            if (File.Exists(this._licenseFile))
            {
                var message = string.Empty;
                WfComponent.Utils.FileUtils.FileCopy(
                    _licenseFile,                           // user select file pass
                    Approbate.DefaultLicenceFilePath,
                    ref message);

                System.Threading.Thread.Sleep(1000);
                if (string.IsNullOrEmpty(message))
                {
                    // copy success.
                    if (EnvInfo.IsLicenceInvalid()) // license invalid
                    {
                        ViewClose();                // 閉じる
                        return;                     // IsActivateLicence = false;
                    }
                    else
                    {   //
                        ShowInfoDialog("license is activated.", "license file accept.");
                        Properties.Settings.Default.demo_mode = string.Empty;
                        Properties.Settings.Default.Save();
                        isActivate = true;
                    }
                }
                else
                {
                    ShowErrorDialog("license file copy error");
                }
            }
            // File null (close window) =>  IsActivateLicence = false;
            ViewClose(); // 閉じる
        }
示例#4
0
    // Placed in environment where they can explore for 2-3 mins, no objects.
    public IEnumerator RunExploreScene(Scene s, Logger logger)
    {
        print("ExploreScene(): Starting");

        // Doesn't have GrayScreen

        GameObject curenv = GetEnvGO(Environments, s.envIndex);

        curenv.BroadcastMessage("SpawnPlayerAtIndex", s.playerSpawnIndex);

        // Get player reference
        GameObject player = GameObject.FindWithTag("Player");

        // Setup logger, using environment info component
        EnvInfo envinfo = (EnvInfo)curenv.GetComponent <EnvInfo>();

        logger.StartTrial(Vector3.zero, player, envinfo.GetOrigin()); // No destination in explore mode

        yield return(new WaitForSeconds(s.envTime));

        logger.EndTrial();

        curenv.BroadcastMessage("RemovePlayer");

        print("ExploreScene(): Done");
    }
 public EnvInfo(EnvInfo copy)
 {
     grounded = copy.grounded;
     onslope = copy.onslope;
     inwall = copy.inwall;
     facingslope = copy.facingslope;
     groundDistance = copy.groundDistance;
 }
示例#6
0
        private void AddFileToProject(EnvInfo envInfo, EntityFileInfo fileInfo, bool embededResource = false)
        {
            var item = envInfo.AddFileToProject((Project)fileInfo.Project, fileInfo.FullPath, fileInfo.FileName);

            if (embededResource)
            {
                envInfo.SetItemBuildAction(item, "EmbeddedResource");
            }
        }
示例#7
0
        public CoreDataClientFactory(EnvInfo envInfo, AppInfo appInfo)
        {
            _envInfo = envInfo;
            _appInfo = appInfo;
            _product = $"{_appInfo.Value}; {_envInfo.Value}";

            _httpClientHandler = new HttpClientHandler {
                UseCookies = true
            };
            _setupMessageHandler = new SetupMessageHandler();
            _logMessageHandler   = new LogMessageHandler();
        }
示例#8
0
 public void Refresh()
 {
     if (!LocationHelper._appUriDic.IsEmpty)
     {
         List <string> list = LocationHelper._appUriDic.Keys.ToList <string>();
         IDictionary <string, string> data = null;
         try
         {
             string str = string.Concat(AppContext.LocationServerURI, "api/Location/BatchGetAppLocations");
             DebugUtil.CollectDebugInfo(str, "WJOP.Foundation.Location.LocationHelper.Refresh");
             BatchGetLocationRequest batchGetLocationRequest = new BatchGetLocationRequest()
             {
                 AppKey      = AppContext.AppKey,
                 AppNameList = list
             };
             EnvInfo envInfo = new EnvInfo()
             {
                 IP  = AppContext.IPv4,
                 Env = AppContext.Environment
             };
             batchGetLocationRequest.EnvInfo = envInfo;
             BatchGetLocationRequest batchGetLocationRequest1          = batchGetLocationRequest;
             FoundationResponse <IDictionary <string, string> > result = str.PostWebApi <FoundationResponse <IDictionary <string, string> >, BatchGetLocationRequest>(batchGetLocationRequest1, null, 180000).Result;
             if (!result.IsSuccess)
             {
                 DebugUtil.Log(string.Format("LocationHelper: Failed to Refresh error Message: {0}", result.ErrMsg));
             }
             else
             {
                 data = result.Data;
                 foreach (string key in data.Keys)
                 {
                     DebugUtil.Log(string.Format("WJOP.Foundation.Location.LocationHelper.Refresh key:[{0}],old value [{1}] , new Value:[{2}]", key, LocationHelper._appUriDic[key], data[key]));
                     LocationHelper._appUriDic[key] = data[key];
                 }
             }
         }
         catch (Exception exception1)
         {
             Exception exception = exception1;
             DebugUtil.LogException(exception);
             DebugUtil.CollectDebugInfo(exception, "WJOP.Foundation.Location.LocationHelper.Refresh");
         }
     }
     else
     {
         DebugUtil.Log("WJOP.Foundation.Location.LocationHelper.Refresh: don't need to refresh");
     }
 }
示例#9
0
        private static void Main(string[] args)
        {
            Console.Title = "01.KPP1.2.1 DLL";

            const string customerName = "John Doe";
            Account      bankAccount  = new Account(customerName);

            const int depositeCount  = 3;
            decimal   depositeAmount = 123;

            for (int i = depositeCount; i > 0; i--)
            {
                depositeAmount *= i;
                bankAccount.Deposite(depositeAmount);

                Console.WriteLine("Client: {0} deposite: {1}$.",
                                  customerName, depositeAmount);
                Console.WriteLine("Server: {0} balance: {1}$.",
                                  bankAccount.Owner, bankAccount.Balance);

                string serverDomainName = EnvInfo.GetDomainName();
                Console.WriteLine("Server: AppDomain = \"{0}\".\n",
                                  serverDomainName);
            }

            string clientDomainName = AppDomain.CurrentDomain.FriendlyName;

            Console.WriteLine("Client: AppDomain = \"{0}\".", clientDomainName);
            Console.WriteLine("Server: Account methods:");

            Type accountClsType = bankAccount.GetType();

            MethodInfo[] methods = accountClsType.GetMethods();

            foreach (MethodInfo method in methods)
            {
                Console.WriteLine(method.ToString());
            }

            Type     tAccount            = typeof(Account);
            Assembly accountAssembly     = Assembly.GetAssembly(tAccount);
            string   accountAssemblyPath = EnvInfo.GetAssemblyPath(accountAssembly);

            Console.WriteLine("Account assembly location: {0}",
                              accountAssemblyPath);

            Console.ReadKey();
        }
示例#10
0
        public EntityManagementMain(DTE dte)
        {
            InitializeComponent();
            this.Shown += EntityManagementMain_Shown;

            if (envInfo == null)
            {
                envInfo = new EnvInfo(dte);
            }


            OpenIServiceButton.Tag = EntityFileTypeEnum.EntityServiceInterface;
            OpenJSButton.Tag       = EntityFileTypeEnum.AngularJSController;
            OpenServiceButton.Tag  = EntityFileTypeEnum.EntityService;
            OpenSPButton.Tag       = EntityFileTypeEnum.EntitySP;
        }
示例#11
0
        public SentryTarget(string DSN)
        {
            _client = new RavenClient(new Dsn(DSN), new JsonPacketFactory(), new SentryRequestFactory(), new SentryUserFactory())
            {
                Compression    = true,
                ErrorOnCapture = OnError,
                Release        = BuildInfo.AppVersion.ToString(),
                Environment    = BuildInfo.IsProduction ? "prod" : "dev"
            };

            var env = new EnvInfo();

            _client.Tags.Add("culture", Thread.CurrentThread.CurrentCulture.Name);
            _client.Tags.Add("64_process", Environment.Is64BitProcess.ToString());
            _client.Tags.Add("is_server", EnvInfo.IsWindowsServer().ToString());
            _client.Tags.Add("is_admin", env.IsAdministrator.ToString());
            _client.Tags.Add("is_gui", env.IsGui.ToString());
        }
示例#12
0
        private string GetAppLocation(string appName)
        {
            string data = null;

            try
            {
                string str = string.Concat(AppContext.LocationServerURI, "api/Location/GetAppLocation");
                DebugUtil.CollectDebugInfo(str, "WJOP.Foundation.Location.LocationHelper.GetAppUris line:70");
                GetLocationRequest getLocationRequest = new GetLocationRequest()
                {
                    AppKey  = AppContext.AppKey,
                    AppName = appName
                };
                EnvInfo envInfo = new EnvInfo()
                {
                    IP  = AppContext.IPv4,
                    Env = AppContext.Environment
                };
                getLocationRequest.EnvInfo = envInfo;
                GetLocationRequest          getLocationRequest1 = getLocationRequest;
                FoundationResponse <string> result = str.PostWebApi <FoundationResponse <string>, GetLocationRequest>(getLocationRequest1, null, 180000).Result;
                if (!result.IsSuccess)
                {
                    DebugUtil.Log(string.Format("LocationHelper: Failed to match service uri for {0}, error Message: {1}", appName, result.ErrMsg));
                }
                else
                {
                    DebugUtil.Log(string.Format("LocationHelper: Found service uri for {0} : {1}", appName, result.Data));
                    data = result.Data;
                }
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                DebugUtil.LogException(exception);
                DebugUtil.CollectDebugInfo(exception, "WJOP.Foundation.Location.LocationHelper.GetAppUris line:98");
            }
            return(data);
        }
    public void raycastGround(Bounds bounds, float margin, ref EnvInfo envInfo)
    {
        if (float.IsNaN(margin) || margin < 0)
            throw new System.ArgumentException("Margin Must be non-negative float");
        if (margin == 0)
            margin = groundMargin;


        envInfo.grounded = envInfo.onslope = false;

        RaycastHit2D rayHit = new RaycastHit2D();

        for (float i = 0; i <= raycastPrecision; i++)
        {
            Vector2 from = new Vector2(
                bounds.min.x + i / raycastPrecision * 2 * bounds.extents.x,
                bounds.max.y
            );
            Vector2 to = from;
            to.y = bounds.min.y - margin;

            //RaycastHits.Add(new Raycast() { from = from, to = to });
            rayHit = Physics2D.Raycast(from, to - from, (to - from).magnitude, 1 << LayerMask.NameToLayer("Environment"));
            Debug.DrawRay(from, to - from, Color.white);
            if (rayHit)
            {
                envInfo.grounded = true;
                var distance = Mathf.Abs(rayHit.distance - bounds.extents.y * 2);
                if (distance > groundMargin)
                    envInfo.groundDistance = distance;
                var angle = Vector2.Angle(rayHit.normal, from - to);
                if (Mathf.Abs(angle) > 5)
                {
                    envInfo.onslope = true;
                }
            }
        }

    }
示例#14
0
        private void SubmitResult()
        {
            var postOperationInstallRecords = _installerClient.GetRecords();
            var diff = new DiffGenerator <WindowsInstallerRecord>(_preOperationInstallRecords, postOperationInstallRecords, c => $"{c.Is64}_{c.Id}");

            var envInfo = new EnvInfo();

            var report = new InstallerReport
            {
                PackageId        = _packageId,
                InstallerRecords = new ChangeSet <WindowsInstallerRecord>
                {
                    Added   = diff.Added().ToList(),
                    Removed = diff.Removed().ToList(),
                    Updated = diff.Updated().ToList()
                },
                Interactivity = InteractivityLevel,
                Duration      = _stopWatch.Elapsed.TotalSeconds,
                Engine        = Whisperer?.InstallMethod.ToString(),
                IsAdmin       = envInfo.IsAdministrator,
                IsGui         = envInfo.IsGui
            };


            if (Process != null)
            {
                report.ExitCode = Process.ExitCode;
            }

            if (Exception != null)
            {
                report.ExitCode = Exception.ExitCode;
                report.ErrorCat = Exception.ExitReason?.Category.ToString();
            }

            _nexClient.SubmitReport(report).Wait();
        }
示例#15
0
    //---------------------------------------------------------------------------------------------------
    //---------------------------------------------------------------------------------------------------

    //Now that the bot has chosen a place to reach, tell it how to get there
    private void actionsTakenToExecutePath()
    {
        //check for gaps in the way if the bot is heading far right
        if (action.x > 0 && action.direction == 'G')
        {
            for (int i = 1; i < action.x; i++)
            {
                EnvInfo nextRaycast = info[new EnvKey('G', i, action.y)];

                //some gap is in the way, so the bot will remember its coordinate to jump over it
                if (nextRaycast.location().y < info[action].location().y - 0.1f)
                {
                    check                 = 2;
                    jumpCoordinate        = nextRaycast.location().x;
                    ceilingCheckAboveJump = new EnvKey('C', i, action.y);
                    break;
                }
            }
        }

        //check for gaps in the way if the bot is heading far left
        if (action.x < 0 && action.direction == 'G')
        {
            for (int i = -1; i > action.x; i--)
            {
                EnvInfo nextRaycast = info[new EnvKey('G', i, action.y)];

                //some gap is in the way, so the bot will remember its coordinate to jump over it
                if (nextRaycast.location().y < info[action].location().y - 0.1f)
                {
                    check                 = 2;
                    jumpCoordinate        = nextRaycast.location().x;
                    ceilingCheckAboveJump = new EnvKey('C', i, action.y);
                    break;
                }
            }
        }

        //if there is a gap in the way as the bot heads left or right
        if (action.x != 0 && action.direction == 'G' && check == 2)
        {
            dontJump = false;

            //if there is a ceiling in the way, the bot will jump when its closer to its end destination to avoid head butting into the ceiling
            if (info[new EnvKey(ceilingCheckAboveJump.direction, ceilingCheckAboveJump.x + (int)Mathf.Sign(action.x), ceilingCheckAboveJump.y)].location().y < transform.position.y + 2f)
            {
                dontJump = true;
            }
        }

        //if heading left or right in a hallway, define the spot where the bot must refigure out what to do
        if (action.direction == 'R')
        {
            endSpot = new Vector2(info[action].location().x - 2, 0);
        }

        if (action.direction == 'L')
        {
            endSpot = new Vector2(info[action].location().x + 2, 0);
        }
    }
示例#16
0
 public override void ApplyEnvInfo(EnvInfo info)
 {
 }
示例#17
0
 public EnvResult(EnvInfo env)
 {
     OS       = env.OSName;
     TimeInfo = env.Time;
 }
示例#18
0
    //---------------------------------------------------------------------------------------------------
    //---------------------------------------------------------------------------------------------------

    //bot randomly chooses to go left or right, then picks a destination to their left or right
    private EnvKey pickPossibleAction()
    {
        foreach (EnvKey key in possibleLeftActions)
        {
            Debug.LogFormat("Left| {0}: {1}, {2}", key.direction, key.x, key.y);
        }

        foreach (EnvKey key in possibleRightActions)
        {
            Debug.LogFormat("Right| {0}: {1}, {2}", key.direction, key.x, key.y);
        }

        //bot randomly picks a direction, but gives greater weight to moving in the same direction as before
        int chooseDirection = Random.Range(0, 100);

        chooseDirection = (lastMovement == -1) ? (chooseDirection - 20) : chooseDirection + 20;

        //if the bot is on a ramp, it recalculates its decision super often, so make it super inclined to continue int he same direction
        EnvInfo ground     = info[new EnvKey('G', 0, 0)];
        float   groundTilt = (ground.gameObject()) ? ground.gameObject().transform.localEulerAngles.z : 0;

        if (ground.gameObject() && transform.position.y - ground.location().y < 1.6f && groundIsRamp(groundTilt))
        {
            chooseDirection += 40 * lastMovement;
            //Debug.Log("on ramp");
        }
        // else
        //     Debug.Log("off ramp " + ground + ", " + (transform.position.y - ground.location().y) + ", " + groundIsRamp(groundTilt));

        //sometimes the bot MUST go left or MUST go right
        if (possibleLeftActions.Count == 0)
        {
            chooseDirection = 50;
        }
        else if (possibleRightActions.Count == 0)
        {
            chooseDirection = 0;
        }

        //for debugging purposes
        if (testSpecificAction)
        {
            return(testKey);
        }

        Debug.Log(chooseDirection + ", " + lastMovement);
        //pick a left or right destination
        if (chooseDirection < 50 && possibleLeftActions.Count > 0)
        {
            int choice = Random.Range(0, possibleLeftActions.Count);
            return(possibleLeftActions[choice]);
        }

        else if (chooseDirection >= 50 && possibleRightActions.Count > 0)
        {
            int choice = Random.Range(0, possibleRightActions.Count);
            return(possibleRightActions[choice]);
        }

        //if the bot somehow has no left/right paths it found (should be impossible), pick a random direction
        else
        {
            Debug.LogError("both action lists were empty :(");

            int  r   = Random.Range(0, 10);
            char dir = (r <= 4) ? 'R' : 'L';
            return(new EnvKey(dir, 0, 0));
        }
    }
示例#19
0
    //
    // Scene logics
    //

    public IEnumerator RunNormalScene(Scene s, Logger logger)
    {
        print("RunNormalScene(): Starting");

        // Show GrayScreen
        yield return(StartCoroutine(ShowGrayScreen(s.objShowIndex, s.showTime, s.greyScreenTime)));

        // Env we'll be sending message to
        GameObject curenv = GetEnvGO(Environments, s.envIndex);

        // Setup player
        if (s.playerSpawnIndex >= 0)
        {
            // Player index of -1 or less implies we dont respawn player. Used for searchfind.
            Environments.BroadcastMessage("RemovePlayer");
            curenv.BroadcastMessage("SpawnPlayerAtIndex", s.playerSpawnIndex);
        }
        GameObject player = GameObject.FindWithTag("Player");

        player.SendMessage("EnableInput");

        // Setup trigger object
        curenv.BroadcastMessage("ActivateObjTriggerAtIndex",
                                new ObjSpawner.TriggerInfo(s.objSpawnIndex, TriggerCallback, s.objShowIndex, globalConfig.objTriggerRadius));
        if (s.showObjAlways)
        {
            curenv.BroadcastMessage("ShowSelf");
        }

        Vector3 objpos = GameObject.FindWithTag("GoalTrigger").transform.position;

        // Setup Landmark
        curenv.BroadcastMessage("ShowLandmark", s.landmarkSpawnIndex);

        // Setup logger, using environment info component
        EnvInfo envinfo = (EnvInfo)curenv.GetComponent <EnvInfo>();

        logger.StartTrial(envinfo.GetActiveTriggerObj().transform.position, player, envinfo.GetOrigin());

        // Wait for player to find target
        float curtime = Time.time;

        yield return(new WaitUntil(() =>
                                   (s.showObjAlways ?
                                    fplayerfoundtarget :
                                    (Input.GetKeyDown(globalConfig.actionKey) || Time.time - curtime >= s.envTime))));

        bool ftimedout = Time.time - curtime >= s.envTime;

        // Log player doing action/timing out
        logger.WriteAction(ftimedout ? "timeout" : "action");

        // Freeze player controls
        player.SendMessage("DisableInput");

        // Check if player found target after the press
        bool ffoundtarget = !(Time.time - curtime >= s.envTime) &&
                            (s.showObjAlways ?
                             fplayerfoundtarget :
                             (globalConfig.objTriggerRadius + player.GetComponent <CharacterController>().radius) >=
                             Vector2.Distance(Helper.ToVector2(objpos),
                                              Helper.ToVector2(player.transform.position)));

        print(String.Format("RunScene(): ffoundtarget: '{0}'", ffoundtarget));

        PlayerAction playerAction = (PlayerAction)player.GetComponent <PlayerAction>();

        if (ffoundtarget)
        {
            print("You found the target without having to be shown it!");
            curenv.BroadcastMessage("ShowSelf");

            // Turn player towards object
            if (!s.showObjAlways)
            {
                yield return(StartCoroutine(playerAction.PlayerLookTowards()));
            }
        }
        else
        {
            print("You didn't find the target in time. Let me show it to you...");

            // Turn the target on! Show the billboarded sprite!
            curenv.BroadcastMessage("ShowSelf");

            // Turn player towards object
            yield return(StartCoroutine(playerAction.PlayerLookTowards()));

            // Reset target
            ResetCallbacks();

            // Unfreeze controls
            player.SendMessage("EnableInput");

            print("...now go find the target!");

            float curtimetwo = Time.time;
            yield return(new WaitUntil(() => fplayerfoundtarget || Time.time - curtimetwo >= s.envTimeTwo));

            // Freeze player controls
            player.SendMessage("DisableInput");
        }

        if (!s.showObjAlways)
        {
            yield return(StartCoroutine(OnFindTarget(player)));
        }

        curenv.BroadcastMessage("HideSelf");

        logger.EndTrial();

        curenv.BroadcastMessage("DeactiveateTriggers");
        curenv.BroadcastMessage("HideLandmark");

        ResetCallbacks();

        yield return(StartCoroutine(ShowGrayScreen(-1, 0.0f, s.greyScreenTimeTwo)));

        print("Scene(): Done");
    }
示例#20
0
    //---------------------------------------------------------------------------------------------------
    //---------------------------------------------------------------------------------------------------

    //bot makes a plan of action (determines place to reach) and starts moving
    private void figureOutWhereToHeadTo()
    {
        //resest action lists + variables
        possibleLeftActions.Clear();
        possibleRightActions.Clear();
        jumpPlatforms.Clear();
        holeSpottedB4 = false;

        //get x position of closest left and right wall
        float rightWallLocation = info[new EnvKey('R', 0, 0)].location().x;
        float leftWallLocation  = info[new EnvKey('L', 0, 0)].location().x;

        //bot takes into account it's last action/location
        lastAction   = action.Equals(null) ? 'A' : action.direction;
        lastMovement = action.Equals(null) ? 1 : (int)Mathf.Sign(action.x);

        //the bot looks to its left for 1) openings in the floor it can drop down in 2) seperate platforms it can jump to
        for (int offset = -1; offset >= -5; offset--)
        {
            EnvKey floorCheck     = new EnvKey('G', offset, 0);
            EnvKey prevFloorCheck = new EnvKey('G', offset + 1, 0);

            //make sure this opening in the floor is not behind a wall (as the bot can't just walk straight to it then)
            if (info[floorCheck].location().x > leftWallLocation)
            {
                //consider going to the first drop down opening on it's left
                if (info[floorCheck].location().y <= transform.position.y - 3.2f && !holeSpottedB4)
                {
                    holeSpottedB4 = true;
                    possibleLeftActions.Add(floorCheck);
                }

                //consider going to the first seperate platform it can jump to on it's left
                if (offset != -1 && info[floorCheck].location().y > transform.position.y - 6.5f && info[prevFloorCheck].location().y <= info[floorCheck].location().y - 0.1f && holeSpottedB4)
                {
                    possibleLeftActions.Add(floorCheck);
                }
            }
        }

        //reset hole spotted variable
        holeSpottedB4 = false;

        //the bot looks to its right for 1) openings in the floor it can drop down in 2) seperate platforms it can jump to
        for (int offset = 1; offset <= 5; offset++)
        {
            EnvKey floorCheck     = new EnvKey('G', offset, 0);
            EnvKey prevFloorCheck = new EnvKey('G', offset - 1, 0);

            //make sure this opening in the floor is not behind a wall (as the bot can't just walk straight to it then)
            if (info[floorCheck].location().x < rightWallLocation)
            {
                //consider going to the first drop down opening on it's right
                if (info[floorCheck].location().y <= transform.position.y - 3.2f && !holeSpottedB4)
                {
                    holeSpottedB4 = true;
                    possibleRightActions.Add(floorCheck);
                }

                //consider going to the first seperate platform it can jump to on it's right
                else if (offset != 1 && info[floorCheck].location().y > transform.position.y - 6.5f && info[prevFloorCheck].location().y <= info[floorCheck].location().y - 0.1f && holeSpottedB4)
                {
                    possibleRightActions.Add(floorCheck);
                }
            }
        }

        //if there is a hallway to the right, consider going there
        if (possibleRightActions.Count <= 1 && rightWallLocation > transform.position.x + 2f)
        {
            //bot should usually consider going right (if it wasn't already going left or if it can't go LEFT next turn)
            if (lastAction != 'L' || leftWallLocation >= transform.position.x - 2.5f)
            {
                possibleRightActions.Add(new EnvKey('R', 0, 0));
            }

            //if the bot was previously heading left, it should rarely consider going right
            else if (lastAction == 'L')
            {
                int r = Random.Range(0, 10);
                if (r >= 9)
                {
                    possibleRightActions.Add(new EnvKey('R', 0, 0));
                }
            }
        }

        //if there is a hallway to the left, still consider going there
        if (possibleLeftActions.Count <= 1 && leftWallLocation < transform.position.x - 2f)
        {
            //bot should usually consider going left  (if it wasn't already going right or if it can't go right next turn)
            if (lastAction != 'R' || rightWallLocation <= transform.position.x + 2.5f)
            {
                possibleLeftActions.Add(new EnvKey('L', 0, 0));
            }

            //if the bot was previously heading right, it should rarely consider going left
            else if (lastAction == 'R')
            {
                int r = Random.Range(0, 10);
                if (r >= 9)
                {
                    possibleLeftActions.Add(new EnvKey('L', 0, 0));
                }
            }
        }

        //the bot checks for openings in the ceiling
        for (int offset = -5; offset <= 5; offset++)
        {
            //get the y coordinate of the ceiling above the player
            EnvKey  ceilingCheck = new EnvKey('C', offset, 0);
            EnvInfo ceiling      = info[ceilingCheck];

            //get the expected height a ceiling should be (for a normal ceiling with no opening)
            float expectedHeight = 4f + transform.position.y;
            float ceilingHeight  = ceiling.location().y;

            //if there is a gap in the ceiling, and its not behind a left or right wall
            if (ceilingHeight > expectedHeight && ceiling.location().x < rightWallLocation && ceiling.location().x > leftWallLocation)
            {
                //if the bot theoretically jumped through the ceiling gap, calculate how far back the left and right walls are on the new platform they would land on
                Vector2 rayCastOrigin = new Vector2(transform.position.x + offset * 1.5f, transform.position.y + 4f);

                RaycastHit2D leftHit  = Physics2D.Raycast(rayCastOrigin, Vector2.left, 9f, Constants.map);
                RaycastHit2D rightHit = Physics2D.Raycast(rayCastOrigin, Vector2.right, 9f, Constants.map);

                float leftUpperWall  = (leftHit.collider != null) ? leftHit.point.x : rayCastOrigin.x - 9;
                float rightUpperWall = (rightHit.collider != null) ? rightHit.point.x : rayCastOrigin.x + 9;

                float rightUpperWallDistance = rightUpperWall - rayCastOrigin.x;
                float leftUpperWallDistance  = rayCastOrigin.x - leftUpperWall;

                //setting these variables to miscellaneous values to avoid null errors
                EnvInfo    leftCeiling = info[new EnvKey('C', 0, 0)];
                EnvInfo    rightCeiling = info[new EnvKey('C', 0, 0)];
                float      leftCeilingHeight = 0, rightCeilingHeight = 0;
                GameObject leftCeilingObject = null, rightCeilingObject = null;

                //can't do left ceiling checks for the left most ceiling and vice versa on the right side
                if (offset != -5)
                {
                    leftCeiling       = info[new EnvKey('C', offset - 1, 0)];
                    leftCeilingHeight = leftCeiling.location().y;
                    leftCeilingObject = leftCeiling.gameObject();
                }
                if (offset != 5)
                {
                    rightCeiling       = info[new EnvKey('C', offset + 1, 0)];
                    rightCeilingHeight = rightCeiling.location().y;
                    rightCeilingObject = rightCeiling.gameObject();
                }

                GameObject groundObject = info[new EnvKey('G', 0, 0)].gameObject();

                //get the tilt of the walls directly to the left and right of the bot right now
                EnvInfo rightWall     = info[new EnvKey('R', 0, 0)];
                float   rightWallTilt = rightWall.gameObject() ? rightWall.gameObject().transform.eulerAngles.z : 0f;

                EnvInfo leftWall     = info[new EnvKey('L', 0, 0)];
                float   leftWallTilt = leftWall.gameObject() ? leftWall.gameObject().transform.eulerAngles.z : 0f;

                //if bot spots an opening in the ceiling to its left or right and there is ceiling directly to the right of the opening,
                //then add this jump as a possible action as long as there is no nearby ramp to the right

                if (offset != 5 && rightCeilingHeight < expectedHeight && rightUpperWallDistance > 2f && rightCeilingObject != groundObject &&
                    (!rightWall.gameObject() || Mathf.Abs(rightCeiling.location().x - rightWall.location().x) > 1.51f || !wallIsActuallyARamp(rightWallTilt)))
                {
                    if (offset > 0)
                    {
                        possibleRightActions.Add(ceilingCheck);
                    }
                    else if (offset < 0)
                    {
                        possibleLeftActions.Add(ceilingCheck);
                    }
                    else if (offset == 0)
                    {
                        if (ceiling.location().x >= transform.position.x)
                        {
                            possibleRightActions.Add(ceilingCheck);
                        }
                        else
                        {
                            possibleLeftActions.Add(ceilingCheck);
                        }
                    }

                    jumpPlatforms.Add(ceilingCheck, "right");
                    jumpToHeight = transform.position.y + 4f;
                }

                //if bot spots an opening in the ceiling to its left or right, but there is ceiling directly to the left of the opening in the ceiling, then add this jump as a possible action
                else if (offset != -5 && leftCeilingHeight < expectedHeight && leftUpperWallDistance > 2f && leftCeilingObject != groundObject &&
                         (!leftWall.gameObject() || Mathf.Abs(leftCeiling.location().x - leftWall.location().x) > 1.51f || !wallIsActuallyARamp(leftWallTilt)))
                {
                    if (offset > 0)
                    {
                        possibleRightActions.Add(ceilingCheck);
                    }
                    else if (offset < 0)
                    {
                        possibleLeftActions.Add(ceilingCheck);
                    }
                    else if (offset == 0)
                    {
                        if (ceiling.location().x <= transform.position.x)
                        {
                            possibleLeftActions.Add(ceilingCheck);
                        }
                        else
                        {
                            possibleRightActions.Add(ceilingCheck);
                        }
                    }

                    jumpPlatforms.Add(ceilingCheck, "left");
                    jumpToHeight = transform.position.y + 4f;
                }
            }
        }

        //bot chooses where to head to
        action  = pickPossibleAction();
        endSpot = info[action].location();

        action.printColored();

        //bot heads to the place it chose
        if (action.direction == 'G')
        {
            check = 1;
            dir   = Mathf.Sign(action.x);
        }
        else if (action.direction == 'R')
        {
            check = 201;
            dir   = 1;
        }
        else if (action.direction == 'L')
        {
            check = 201;
            dir   = -1;
        }
        else if (action.direction == 'C')
        {
            dir   = Mathf.Sign(action.x);
            check = 301;
        }

        rig.velocity = new Vector2(botSpeed * dir, rig.velocity.y);
        actionsTakenToExecutePath();
    }
    public void raycastForward(Bounds bounds, Facing facing, float margin, ref EnvInfo envInfo)
    {
        if (float.IsNaN(margin) || margin < 0)
            throw new System.ArgumentException("Margin Must be non-negative float");
        if (margin == 0)
            margin = wallMargin;

        envInfo.inwall = envInfo.onwall = envInfo.facingslope = false;

        RaycastHit2D rayHit = new RaycastHit2D();

        for (float i = 0; i <= raycastPrecision; i++)
        {
            Vector2 from = new Vector2(
                facing == Facing.right ? bounds.min.x + wallMargin : bounds.max.x - wallMargin,
                bounds.min.y + i / raycastPrecision * 2 * bounds.extents.y
            );
            Vector2 to = from;
            to.x = facing == Facing.right ? bounds.max.x + margin : bounds.min.x - margin;

            RaycastHits.Add(new Raycast() { from = from, to = to });
            rayHit = Physics2D.Raycast(from, to - from, (to - from).magnitude, 1 << LayerMask.NameToLayer("Environment"));
            Debug.DrawRay(from, to - from, Color.white);
            if (rayHit)
            {
                envInfo.inwall = true;
                var distance = Mathf.Abs(rayHit.distance - (bounds.extents.x * 2 + wallMargin));
                if (distance > wallMargin)
                    envInfo.wallDistance = distance;
                break;
            }
        }
    }
示例#22
0
        private void LoadXMLInfo()
        {
            switch (this.type)
            {
            case EnvType.IIS:
            {
                solutionFilePath      = EnvInfo.solutionFilePathForIIS;
                iotServerPath         = EnvInfo.iotServerFilePathForIIS;
                dispatchIotServerPath = EnvInfo.iotDispatchServerFilePathForIIS;
                ErrorPolicy           = "请检查IIS应用程序池“标识”是否设置为“LocalSystem”权限器。";
            }
            break;

            case EnvType.CS:
            {
                solutionFilePath      = EnvInfo.solutionFilePathForCS;
                iotServerPath         = EnvInfo.iotServerFilePathForCS;
                dispatchIotServerPath = EnvInfo.iotDispatchServerFilePathForCS;
                ErrorPolicy           = "请检查程序是否以管理员方式启动";
            }
            break;

            default:
            {
                ErrorPolicy = "未知服务宿主类型";
                EnvIsOkay   = false;
                return;
            }
            }
            // 选择加载的需要项目名称
            if (!XMLHelper.LoadSolutionInfo(solutionFilePath, out string solutionName, out string errMsg))
            {
                ErrorPolicy = errMsg;
                EnvIsOkay   = false;
                return;
            }
            // 找到该项目配置文件
            if (!XMLHelper.LoadProjectConfigPath(solutionFilePath, solutionName, out projectConfigPath, out errMsg))
            {
                ErrorPolicy = errMsg;
                EnvIsOkay   = false;
                return;
            }
            // 找到该项目配置文件
            if (!XMLHelper.LoadProjectInfo(projectConfigPath, out string projectServerName, out errMsg))
            {
                ErrorPolicy = errMsg;
                EnvIsOkay   = false;
                return;
            }
            // 找到是否需要OPCServer
            if (!GetIsNeedOPCServer(out errMsg))
            {
                ErrorPolicy = errMsg;
                EnvIsOkay   = false;
                return;
            }
            // 核心服务信息
            serverName     = EnvInfo.GetServerName(projectServerName);
            serverDescribe = EnvInfo.GetServerDescribe(projectServerName);
            // 调度服务信息
            dispatchServerName     = EnvInfo.GetDispatchServerName(projectServerName);
            dispatchServerDescribe = EnvInfo.GetDispatchServerDescribe(projectServerName);
            // 成功标志置位
            EnvIsOkay = true;
        }
示例#23
0
 public void SetEnvInfo(EnvInfo info)
 {
     env_info = info;
 }