Exemplo n.º 1
0
        private static int ExpandValue(Node n, Node[,] grid)
        {
            int n1 = 0, n2 = 0, n3 = 0, n4 = 0;

            if (n.visited || !n.walkable)
            {
                return(0);
            }
            else
            {
                n.visited = true;
                Node tmpNode = null;
                try
                {
                    if (n.x > 0)  //test left
                    //Debug.WriteLine("left");
                    {
                        tmpNode = grid[n.y, n.x - 1]; // chromosome.Genes[n.Y * _currentMap.Height + n.X - 1];
                        if (tmpNode != null && !tmpNode.visited && tmpNode.walkable)
                        {
                            n1 = ExpandValue(tmpNode, grid);
                        }
                    }
                    if (n.x < APIClass.CurrentMap.Width - 1)  //test right
                    //Debug.WriteLine("right");
                    {
                        tmpNode = grid[n.y, n.x + 1]; // chromosome.Genes[n.Y * _currentMap.Height + n.X - 1];
                        if (tmpNode != null && !tmpNode.visited && tmpNode.walkable)
                        {
                            n2 = ExpandValue(tmpNode, grid);
                        }
                    }
                    if (n.y > 0)  //test top
                    //Debug.WriteLine("top");
                    {
                        tmpNode = grid[n.y - 1, n.x]; // chromosome.Genes[n.Y * _currentMap.Height + n.X - 1];
                        if (tmpNode != null && !tmpNode.visited && tmpNode.walkable)
                        {
                            n3 = ExpandValue(tmpNode, grid);
                        }
                    }
                    if (n.y < APIClass.CurrentMap.Height - 1)  //test bottom
                    //Debug.WriteLine("bottom");
                    {
                        tmpNode = grid[n.y + 1, n.x]; // chromosome.Genes[n.Y * _currentMap.Height + n.X - 1];
                        if (tmpNode != null && !tmpNode.visited && tmpNode.walkable)
                        {
                            n4 = ExpandValue(tmpNode, grid);
                        }
                    }
                }
                catch (Exception e) { DebugUtilities.DebugException(e); }
            }
            return(1 + n1 + n2 + n3 + n4);
        }
    public void SetOrientedSpaceRotation(RigidBoneSystemInputs inputs, TwistSwing orientatedSpaceRotation, bool applyClamp = false)
    {
        DebugUtilities.AssertFinite(orientatedSpaceRotation);

        if (applyClamp)
        {
            orientatedSpaceRotation = Constraint.Clamp(orientatedSpaceRotation);
        }

        inputs.Rotations[Index] = orientatedSpaceRotation;
    }
Exemplo n.º 3
0
 void SetupMoveAndInteraction()
 {
     if (activeLine != null)
     {
         DebugUtilities.Assert(activeLine != null, "Active Line is null after act");
         bool canMove     = activeLine.AvatarAllowedToMove();
         bool canInteract = activeLine.AvatarAllowedToInteract();
         SetInteractionForMainCharacter(canInteract);
         SetMovementForMainCharacter(canMove);
     }
 }
Exemplo n.º 4
0
 public void SetLogicCamera(LogicCamera logicCameraToFollow)
 {
     DebugUtilities.Assert(logicCameraToFollow != null, "Camera can not be null!");
     if (logicCamera)
     {
         //    cameraInfo.pivotRotation = logicCamera.transform.rotation;
     }
     logicCamera = logicCameraToFollow;
     // logicCamera.OnCameraSwitch(cameraInfo);
     cameraInfo.cameraSwitched = true;
 }
Exemplo n.º 5
0
        private void beginMouseOperation()
        {
            DebugUtilities.Assert(_gotMouseDown == false, "beginMouseOperation called when already in mouse operation");
            _gotMouseDown = true;

            // Use the handler specified on Model, if not null. Otherwise, use ourself.
            _currentMouseHandler = _CanvasViewModel.CanvasViewMouseHandler != null ? _CanvasViewModel.CanvasViewMouseHandler : this;

            // Don't create undo states at every drag update.
            _CanvasViewModel._DocumentViewModel.dm_DocumentDataModel.BeginOperation("CanvasView mouse operation");
        }
Exemplo n.º 6
0
    protected override void Act()
    {
        Debug.Log("Starting Arrive At Destination: " + areaName);
        goalObject = GameObject.Find(areaName);
        DebugUtilities.Assert(goalObject != null, "Couldn't find object:" + areaName);

        var avatar = actingInScene.GetActor("Tyra");

        avatarQuest = avatar.GetComponentInChildren <AvatarQuest>();
        avatarQuest.AddGoalObject(goalObject);
    }
Exemplo n.º 7
0
 public static void OV_sendRaycast(PlayerInput instance, RaycastInfo info)
 {
     if (Packets.Count > 0)
     {
         Packets.Last().clientsideInputs.Add(info);
     }
     else
     {
         DebugUtilities.Log("f**k");
     }
 }
Exemplo n.º 8
0
    private void SetupGameArea()
    {
        // Limit the game area into a 4:3 shape
        float   width      = 4f * Camera.main.orthographicSize * 2f / 3f;
        Vector3 topRight   = Camera.main.transform.position + new Vector3(width / 2f, Camera.main.orthographicSize, -Camera.main.transform.position.z);
        Vector3 bottomLeft = Camera.main.transform.position - new Vector3(width / 2f, Camera.main.orthographicSize, Camera.main.transform.position.z);

        // Lift up the game area bottom to floor level
        m_gameArea = new Rect(bottomLeft.x, 0f, topRight.x - bottomLeft.x, topRight.y - 0f);
        DebugUtilities.DrawArrow(bottomLeft, topRight, Vector3.back, Color.blue, 0, 0.5f);
    }
Exemplo n.º 9
0
    /// <summary>
    /// Only one round routine can be active at any given time, this makes sure that holds true
    /// </summary>
    /// <param name="routine">IEnumerator to run</param>
    /// <returns>Started Coroutine</returns>
    private Coroutine StartRoundRoutine(System.Collections.IEnumerator routine)
    {
        if (m_roundRoutineIEnumerator != null)
        {
            Debug.LogWarning(DebugUtilities.AddTimestampPrefix("ScenarioManager stopping previous round routine!"));
            StopCoroutine(m_roundRoutineIEnumerator);
        }

        m_roundRoutineIEnumerator = routine;
        return(StartCoroutine(routine));
    }
Exemplo n.º 10
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }

        if (ShowDebugInfo)
        {
            DebugText.text = DebugUtilities.GetArrayContents(shapes);
        }

        if (state == GameState.None)
        {
            //user has clicked or touched
            if (Input.GetMouseButtonDown(0))
            {
                //get the hit position
                var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
                if (hit.collider != null) //we have a hit!!!
                {
                    hitGo = hit.collider.gameObject;
                    state = GameState.SelectionStarted;
                }
            }
        }
        else if (state == GameState.SelectionStarted)
        {
            //user dragged
            if (Input.GetMouseButton(0))
            {
                var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
                //we have a hit
                if (hit.collider != null && hitGo != hit.collider.gameObject)
                {
                    //user did a hit, no need to show him hints
                    StopCheckForPotentialMatches();

                    //if the two shapes are diagonally aligned (different row and column), just return
                    if (!Utilities.AreVerticalOrHorizontalNeighbors(hitGo.GetComponent <Shape>(),
                                                                    hit.collider.gameObject.GetComponent <Shape>()))
                    {
                        state = GameState.None;
                    }
                    else
                    {
                        state = GameState.Animating;
                        FixSortingLayer(hitGo, hit.collider.gameObject);
                        StartCoroutine(FindMatchesAndCollapse(hit));
                    }
                }
            }
        }
    }
Exemplo n.º 11
0
        /// <summary>
        ///     Configures Application-Pipeline
        /// </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        /// <param name="provider"></param>
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVersionDescriptionProvider provider)
        => app.StartTweakingWith(_logger, Configuration)
        .Tweak(a => a.UseRouting(), "adding routing")
        .Tweak(a => a.UseHttpMetrics(), "adding http-metrics")
        .TweakWhen(c => c.GetSection("EnableLegacyRedirect"),
                   a => a.UseMiddleware <V0RedirectMiddleware>(),
                   "adding V0-Redirect-Middleware")
        .TweakWhen(c => c.GetSection("Authentication:Kestrel:Enabled"),
                   a => a.UseAuthentication(),
                   "adding authentication-hooks",
                   "skipping authentication-hooks")
        .TweakWhen(env.IsDevelopment(), a => a.UseDeveloperExceptionPage(), "adding Development Exception-Handler")
        .TweakWhen(!env.IsDevelopment(), a => a.UseHsts(), "adding HSTS")
        .TweakWhen(!env.IsDevelopment(), a => a.UseHttpsRedirection(), "adding HTTPS-Redirect")
        .Tweak(a => a.ApplicationServices.SetupNLogServiceLocator(), "finishing NLog configuration")
        .Tweak(a => a.UseMiddleware <LoggingMiddleware>(), "adding Correlation-Logging-Middleware")
        .Tweak(a => a.UseCors(policy => policy.AllowAnyHeader()
                              .AllowAnyMethod()
                              .AllowAnyOrigin()),
               "adding CORS")
        .Tweak(a => a.UseSwagger()
               .UseSwaggerUI(options =>
        {
            options.DocExpansion(DocExpansion.None);
            options.DisplayRequestDuration();
            options.EnableDeepLinking();
            options.EnableFilter();
            options.ShowExtensions();

            foreach (var description in provider.ApiVersionDescriptions.OrderByDescending(v => v.ApiVersion))
            {
                options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json",
                                        $"ConfigService {description.GroupName.ToUpperInvariant()}");
            }
        }),
               "adding Swagger/-UI")
        .Tweak(a => a.UseEndpoints(routes => routes.MapControllerRoute("Health", "api/health/status/{depth?}", new
        {
            controller = "Health",
            action     = "Status"
        })),
               "adding Health-Middleware")
        .Tweak(a => a.UseEndpoints(builder => builder.MapControllers()), "adding controller-endpoints")
        .Tweak(a => a.UseEndpoints(builder => builder.MapMetrics()), "adding metrics-endpoints")
        .Tweak(_ =>
        {
            ChangeToken.OnChange(Configuration.GetReloadToken,
                                 conf =>
            {
                conf.ConfigureNLog(_logger);
                _logger.LogInformation(DebugUtilities.FormatConfiguration(conf));
            },
                                 Configuration);
        }, "registering config-reload hook");
Exemplo n.º 12
0
    void AllocateId(int id)
    {
        DebugUtilities.Assert(!StoreMap[id]);
        StoreMap[id] = true;

        BlockStore[id]    = Instantiate(BlockPrefab, Vector3.zero, Quaternion.identity) as Block;
        BlockStore[id].Id = id;
        BlockStore[id].transform.parent = transform;

        BlockCount++;
    }
 void OnTriggerEnter(Collider collider)
 {
     if (canInteract)
     {
         Debug.Log("Collision:" + name);
         var avatar = collider.GetComponentInChildren <CharacterAvatar>();
         DebugUtilities.Assert(avatar != null, "Please set collision masks. Nothing other than CharacterAvatars should trigger this");
         DebugUtilities.Assert(interactable != null, "You must set up interactable for InteractOnTrigger:" + name);
         avatar.PerformPrimaryAction(interactable.gameObject);
     }
 }
Exemplo n.º 14
0
    void PlayNextLine()
    {
        gotoNextLine = false;

        if (SceneIsDone())
        {
            CompletedScene();
            return;
        }

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

        Debug.Log($"play next line {lineIndex} ");
        activeLine = lines[lineIndex];
        if (activeLine)
        {
            Debug.Log("Actorscene " + name + " sets line: " + activeLine.name + " _________________________________________");
        }
        else
        {
            Debug.Log("Actorscene " + name + " has a missing line with index: " + lineIndex + " _________________________________________!!");
        }


#if UNITY_EDITOR
        debugString = name + ": " + activeLine.name;
#endif

        DebugUtilities.Assert(activeLine != null, "Active Line is null");
        lineIndex++;

        if (activeLineNotification != null)
        {
            activeLineNotification(this, activeLine);
        }

        DebugUtilities.Assert(activeLine != null, "Active Line is null before act");
        Debug.Log("ACT: scene: " + activeLine.name + " " + activeLine.GetType());

        activeLine.OnComponentDone   += OnComponentDone;
        activeLine.OnComponentFailed += OnComponentFailed;
        activeLine.OnComponentQuit   += OnComponentQuit;

        activeLine.ActInScene(this);

        SetupMoveAndInteraction();

        isResuming = false;
    }
 // Token: 0x06000174 RID: 372 RVA: 0x0000D0DC File Offset: 0x0000B2DC
 public static void AimMouseTo(float x, float y)
 {
     DebugUtilities.Log(string.Format("yaw:{0}|pitch:{1}|x:{2}|y:{3}", new object[]
     {
         AimbotCoroutines.Yaw,
         AimbotCoroutines.Pitch,
         x,
         y
     }));
     AimbotCoroutines.Yaw   = x;
     AimbotCoroutines.Pitch = y;
 }
Exemplo n.º 16
0
        public void EndOperationWithoutCreatingUndoState(String operationName)
        {
            DebugUtilities.Assert(_operationLevel > 0, "Trying to end operation " + operationName + " that hasn't begun");

            // Debug.WriteLine("End operation #" + _operationLevel + ": " + operationName);

            VerifyState(ModelState.Busy);
            if (--_operationLevel == 0)
            {
                State = ModelState.Ready;
            }
        }
Exemplo n.º 17
0
    void SwitchToCameraWithHighestPriority()
    {
        DebugUtilities.Assert(cameraStack.Count > 0, "Camera stack is empty");
        var cameraHandle = cameraStack[cameraStack.Count - 1];

        Debug.Log("Active Camera " + cameraHandle.CameraName + " target:" + cameraHandle.TargetCamera.name);
        if (cameraApplicator.CurrentCamera != cameraHandle.TargetCamera)
        {
            DebugUtilities.Assert(cameraHandle.TargetCamera != null, "The target camera is null, how is that possible?");
            cameraApplicator.SetLogicCamera(cameraHandle.TargetCamera);
        }
    }
Exemplo n.º 18
0
 public void Stop()
 {
     // Reset.
     if (this.thread != null)
     {
         this.thread.Abort();
         this.thread = null;
                             #if DEBUG
         DebugUtilities.UniversalDebug(this.sourceName, "Stopping Thread.", ref this.debugMessages);
                             #endif
     }
 }
Exemplo n.º 19
0
    void StopFanningMode()
    {
        Debug.Log("Fanning: Stop");
        DebugUtilities.Assert(isInFanMode, "You can not reset if you aren't fanning");
        if (barAnim != null)
        {
            Destroy(barAnim.gameObject);
            barAnim = null;
        }

        isInFanMode = false;
    }
Exemplo n.º 20
0
    void Initiate()
    {
        var mainActorObject = GameObject.FindGameObjectWithTag("Player");

        DebugUtilities.Assert(mainActorObject != null, "Couldn't fint IAvatar from tag Player");
        var avatar = mainActorObject.GetComponentInChildren <IAvatar>();

        DebugUtilities.Assert(avatar != null, "Found an object with tag Player but didn't have an actor.");
        var actorScene = ActorSceneUtility.CreateSceneWithAvatar(actorScenePrefab, avatar);

        actorScene.PlayScene(avatar.playerNotifications);
    }
    protected override void Act()
    {
        Debug.Log("Interactable: " + interactableName);

        goalObject = Interactable.GetInteractableFromName(interactableName);
        DebugUtilities.Assert(goalObject != null, "Couldn't find interactable component on:" + interactableName);

        var avatar = actingInScene.GetActor("Tyra");

        avatarQuest = avatar.GetComponentInChildren <AvatarQuest>();
        avatarQuest.AddGoalObject(goalObject.gameObject);
    }
Exemplo n.º 22
0
    public static Swing To(CartesianAxis twistAxis, Vector3 to)
    {
        DebugUtilities.AssertIsUnit(to);

        float toX = to[((int)twistAxis + 0) % 3];
        float toY = to[((int)twistAxis + 1) % 3];
        float toZ = to[((int)twistAxis + 2) % 3];

        /*
         * To reconstruct the swing quaternion, we need to calculate:
         *     <y, z> = Sin[angle / 2] * rotation-axis
         *     w = Cos[angle / 2]
         *
         * We know:
         *     Cos[angle]
         *       = Dot[twist-axis, to]
         *       = toX
         *
         *     rotation-axis
         *       = Normalize[Cross[twist-axis, to]]
         *       = Normalize[<-toZ, toX>]
         *       = <-toZ, toX> / Sqrt[toX^2 + toZ^2]
         *       = <-toZ, toX> / Sqrt[1 - toX^2]
         *
         * So:
         *     w = Cos[angle / 2]
         *       = Sqrt[(1 + Cos[angle]) / 2]    (half-angle trig identity)
         *       = Sqrt[(1 + toX) / 2]
         *
         *    <y,z>
         *      = Sin[angle / 2] * rotation-axis
         *      = Sqrt[(1 - Cos[angle]) / 2] * rotation-axis    (half-angle trig identity)
         *      = Sqrt[(1 - toX) / 2] * rotation-axis
         *      = Sqrt[(1 - toX) / 2] / Sqrt[1 - toX^2] * <-toZ, toY>
         *      = Sqrt[(1 - toX) / (2 * (1 - toX^2))] * <-toZ, toY>
         *      = Sqrt[(1 - toX) / (2 * (1 - toX) * (1 + toX))] * <-toZ, toY>
         *      = Sqrt[1 / (2 * (1 + toX))] * <-toZ, toY>
         *      = 1 / (2 * w) * <-toZ, toY>
         */
        float ww = (1 + toX);
        float wy = -toZ;
        float wz = +toY;

        if (ww < MathUtil.ZeroTolerance)
        {
            // This is a 180 degree swing (W = 0) so X and Y don't have a unique value
            // I'll arbitrarily use:
            return(new Swing(1, 0));
        }

        return(Swing.MakeUnitized(ww, wy, wz));
    }
 // private IEnumerator BroadcastingRoutine(){
 //  while (true) {
 //      Broadcast();
 //      yield return new WaitForSeconds(this.expireTime);
 //  }
 // }
 private void Broadcast()
 {
             #if DEBUG2
     DebugUtilities.UniversalDebug(this.sourceName, "Broadcasting a message: " + this.broadcastMessage);
             #endif
     this.udpBroadcaster.Broadcast(this.requestData);
     if (!this.udpBroadcaster.flagSuccess)
     {
                     #if DEBUGWARNING
         DebugUtilities.UniversalWarning(this.sourceName, "Couldn't broadcast the message.");
                     #endif
     }
 }
 /// <summary>
 /// Shutdown the sever.
 /// </summary>
 public static void ServerShutdown()
 {
     if (server != null)
     {
         server.Shutdown();
         DebugUtilities.Log("Server is now shutting down...");
     }
     else
     {
         DebugUtilities.Log(msg: "Server does not exists.",
                            type: Utilities.LogType.Warning);
     }
 }
Exemplo n.º 25
0
    public void EndRoundInternal(bool success)
    {
        Debug.Log(DebugUtilities.AddTimestampPrefix("Round is ending..."));

        m_currentRound.End();

        if (OnRoundEndedCallback != null)
        {
            OnRoundEndedCallback.Invoke(success);
        }

        StartRoundRoutine(RoundEndRoutine(success));
    }
Exemplo n.º 26
0
    private void Awake()
    {
        if (s_instance != null)
        {
            Debug.LogError(DebugUtilities.AddTimestampPrefix("Multiple instances of " + typeof(ScenarioManager) + " detected! Destroying additional instance '" + name + "' in favor of the existing one"), s_instance);
            Destroy(gameObject);
            return;
        }

        s_instance = this;

        Debug.Log(DebugUtilities.AddTimestampPrefix("ScenarioManager.Awake()"), this);
    }
Exemplo n.º 27
0
        public void ContainsAny()
        {
            string[]      containedItems = { "Item 1", "Item 2", "Item 3" };
            string[]      incorrectArray = { "Item 0", "Item 4" };
            string[]      correctArray   = { "Item 0", "Item 2", "Item 4", "Item 5" };
            List <string> correctList    = new List <string>()
            {
                "Item 0", "Item 2", "Item 4", "Item 5"
            };

            Assert.IsFalse(incorrectArray.ContainsAny(containedItems), DebugUtilities.FailedAssertMessage("ContainsAny()", 1, false, true));
            Assert.IsTrue(correctArray.ContainsAny(containedItems), DebugUtilities.FailedAssertMessage("ContainsAny()", 2, true, false));
        }
Exemplo n.º 28
0
    public static void SetVolume(float volume)
    {
        if (s_instance == null)
        {
            return;
        }

        if (s_instance.m_audioMixer != null)
        {
            Debug.Log(DebugUtilities.AddTimestampPrefix("Master volume being set to " + volume.ToString("F2") + "dB"));
            s_instance.m_audioMixer.SetFloat("VolumeMaster", volume);
        }
    }
 private void EnableMotionControllerSimulation()
 {
     if (dataProvider == null)
     {
         DebugUtilities.LogVerbose("Creating a new motion controller simulation data provider");
         dataProvider = new SimulatedMotionControllerDataProvider(InputSimulationProfile);
     }
     else if (dataProvider is SimulatedHandDataProvider)
     {
         DebugUtilities.LogVerbose("Replacing hand simulation data provider with motion controller simulation data provider");
         RemoveAllControllerDevices();
         dataProvider = new SimulatedMotionControllerDataProvider(InputSimulationProfile);
     }
 }
Exemplo n.º 30
0
 public void Start()
 {
     if ((this.threadAction != null) && (this.thread == null))
     {
         this.debugMessages = new List <string>();
         // Start the thread.
         this.thread = new Thread(new ThreadStart(ThreadLoop));
         this.thread.IsBackground = true;
         this.thread.Start();
                             #if DEBUG
         DebugUtilities.UniversalDebug(this.sourceName, "Thread Started.", ref this.debugMessages);
                             #endif
     }
 }