コード例 #1
0
ファイル: DungeonLevel.cs プロジェクト: Kuqki/3902_ZJZH
        public void Update(GameTime _gameTime)
        {
            if (CurrentRoom != null)
            {
                CurrentRoom.Update();
            }
            Map.Update(_gameTime);
            Rectangle linkRectangle = Link.GetRectangle();

            if (linkRectangle.Intersects(doors[0]))
            {
                if (CurrentRoom.HasNorth)
                {
                    TempRoom    = CurrentRoom;
                    CurrentRoom = Rooms[Rooms.Count - 1];//switch to the empty room
                    North();
                }
            }
            else if (linkRectangle.Intersects(doors[1]))
            {
                if (CurrentRoom.HasEast)
                {
                    TempRoom    = CurrentRoom;
                    CurrentRoom = Rooms[Rooms.Count - 1];//switch to the empty room
                    East();
                }
            }
            else if (linkRectangle.Intersects(doors[2]))
            {
                if (CurrentRoom.HasSouth)
                {
                    TempRoom    = CurrentRoom;
                    CurrentRoom = Rooms[Rooms.Count - 1];//switch to the empty room
                    South();
                }
            }
            else if (linkRectangle.Intersects(doors[3]))
            {
                if (CurrentRoom.HasWest)
                {
                    TempRoom    = CurrentRoom;
                    CurrentRoom = Rooms[Rooms.Count - 1];//switch to the empty room
                    West();
                }
            }
            if (CurrentRoom != null)
            {
                DetectCollision.linkBlockDetection(this.Link, CurrentRoom.Block);
                DetectCollision.LinkEnemyDetection(this.Link, CurrentRoom.Enemies);
                DetectCollision.linkReceivedItemDetection(this.Link, CurrentRoom.ReceivedItems);
                DetectCollision.linkObtainedItemDetection(this.Link, CurrentRoom.ObtainedItems);
                DetectCollision.EnemyBlockDetection(CurrentRoom.Enemies, CurrentRoom.Block);
                DetectCollision.EnemyProjectileDetection(CurrentRoom.Enemies, this.game.ProjectileFactory);
            }
        }
コード例 #2
0
    // Start is called before the first frame update
    void Awake()
    {
        Rigid     = GetComponentInChildren <Rigidbody>();
        Colli     = GetComponent <DetectCollision>();
        GroundDir = transform.up;
        SetGrounded();

        Cam    = GameObject.FindGameObjectWithTag("MainCamera").transform;
        CamY   = Cam.transform.parent.parent.transform;
        CamFol = Cam.GetComponentInParent <CameraFollow>();

        //detatch rigidbody so it can move freely
        Rigid.transform.parent = null;
    }
コード例 #3
0
ファイル: DungeonLevel.cs プロジェクト: Kuqki/3902_ZJZH
        public void initialize()
        {
            LevelLoader1    = new LevelLoader(game.enemyFactory, game);
            Map             = new Map(this);
            Link            = game.Link;
            Rooms           = new List <IRoom>();
            CurrentRoom     = new Room();
            DetectCollision = new DetectCollision();
            Rooms           = LevelLoader1.LoadRooms(Link);
            Rooms.Add(new Room());
            CurrentRoom = Rooms[0];


            foreach (Room room in Rooms)
            {
                room.Boundary = new List <IBlock>
                {
                    new BoundaryLong(new Vector2(0, 0)),
                    new BoundaryShort(new Vector2(0, (int)((float)GlobalDefinitions.Boundary / GlobalDefinitions.RoomWidth * GlobalDefinitions.GraphicsWidth))),
                    new BoundaryShort(new Vector2(GlobalDefinitions.GraphicsWidth - (int)((float)GlobalDefinitions.Boundary / GlobalDefinitions.RoomWidth * GlobalDefinitions.GraphicsWidth), (int)((float)GlobalDefinitions.Boundary / GlobalDefinitions.RoomWidth * GlobalDefinitions.GraphicsWidth))),
                    new BoundaryLong(new Vector2(0, GlobalDefinitions.GraphicsHeight - (int)((float)GlobalDefinitions.Boundary / GlobalDefinitions.RoomHeight * GlobalDefinitions.GraphicsHeight)))
                };

                room.Block.AddRange(room.Boundary);
            }


            doors = new List <Rectangle>
            {
                new Rectangle((int)(GlobalDefinitions.GraphicsWidth * 0.5 - (float)GlobalDefinitions.DoorWidth / GlobalDefinitions.RoomWidth * GlobalDefinitions.GraphicsWidth * 0.5),
                              0,
                              (int)((float)GlobalDefinitions.DoorWidth / GlobalDefinitions.RoomWidth * GlobalDefinitions.GraphicsWidth),
                              (int)((float)GlobalDefinitions.DoorDepth / GlobalDefinitions.RoomHeight * GlobalDefinitions.GraphicsHeight)), // North, 0
                new Rectangle(GlobalDefinitions.GraphicsWidth - (int)((float)GlobalDefinitions.DoorDepth / GlobalDefinitions.RoomWidth * GlobalDefinitions.GraphicsWidth),
                              (int)(GlobalDefinitions.GraphicsHeight * 0.5 - (float)GlobalDefinitions.DoorWidth / GlobalDefinitions.RoomHeight * GlobalDefinitions.GraphicsHeight * 0.5),
                              (int)((float)GlobalDefinitions.DoorDepth / GlobalDefinitions.RoomWidth * GlobalDefinitions.GraphicsWidth),
                              (int)((float)GlobalDefinitions.DoorWidth / GlobalDefinitions.RoomHeight * GlobalDefinitions.GraphicsHeight)), // East, 1
                new Rectangle((int)(GlobalDefinitions.GraphicsWidth * 0.5 - (float)GlobalDefinitions.DoorWidth / GlobalDefinitions.RoomWidth * GlobalDefinitions.GraphicsWidth * 0.5),
                              GlobalDefinitions.GraphicsHeight - (int)((float)GlobalDefinitions.DoorDepth / GlobalDefinitions.RoomHeight * GlobalDefinitions.GraphicsHeight),
                              (int)((float)GlobalDefinitions.DoorWidth / GlobalDefinitions.RoomWidth * GlobalDefinitions.GraphicsWidth),
                              (int)((float)GlobalDefinitions.DoorDepth / GlobalDefinitions.RoomHeight * GlobalDefinitions.GraphicsHeight)), // South, 2
                new Rectangle(0,
                              (int)(GlobalDefinitions.GraphicsHeight * 0.5 - (float)GlobalDefinitions.DoorWidth / GlobalDefinitions.RoomHeight * GlobalDefinitions.GraphicsHeight * 0.5),
                              (int)((float)GlobalDefinitions.DoorDepth / GlobalDefinitions.RoomWidth * GlobalDefinitions.GraphicsWidth),
                              (int)((float)GlobalDefinitions.DoorWidth / GlobalDefinitions.RoomHeight * GlobalDefinitions.GraphicsHeight)) // West, 3
            };
        }
コード例 #4
0
    // Use this for initialization
    void Start()
    {
        Debug.Log("OptiTrack: Start test.");

        allocateOptiTrackObjects();

        handleOriginalPos = OptiTrackManager.Instance.getPosition(handleRigidbodyIndex);
        handleOriginalRot = OptiTrackManager.Instance.getOrientation(handleRigidbodyIndex);
        handleOriginalRot = handleOriginalRot * Quaternion.Euler(rotationOffset);

        handleLastPos = handleOriginalPos;

        GameObject wrenchFittingObject = GameObject.FindWithTag("WrenchFitting");

        if (wrenchFittingObject != null)
        {
            wrenchFittingController = wrenchFittingObject.GetComponent <DetectCollision> ();
        }
        else
        {
            Debug.Log("OptiTrack: can not find wrenchFittingController");
        }


        GameObject GameControllerObject = GameObject.FindWithTag("GameController");

        if (GameControllerObject != null)
        {
            GameController = GameControllerObject.GetComponent <GameController> ();
        }
        else
        {
            Debug.Log("OptiTrack: can not find GameController");
        }

        GameObject working_object_object = GameObject.FindWithTag("working_object");

        initialize_coupled_position(working_object_object);
//		for (int i = 0; i < position_y.Length; i++) {
//			position_y [i] += working_object_object.transform.position.y;
//		}
//		for (int i = 0; i < position_z.Length; i++) {
//			position_z [i] += working_object_object.transform.position.z;
//		}
    }
コード例 #5
0
        public void InitializeDlll(string path)
        {
            //TO DO FIX
            dllHandle = WindowsUtilities.LoadLibrary(Path.Combine(path, "HookCostume.dll"));
            if (dllHandle != null)
            {
                var initGameAddress = WindowsUtilities.GetProcAddress(dllHandle, "InitGame");
                if (initGameAddress != IntPtr.Zero)
                {
                    initGame = (InitGame)Marshal.GetDelegateForFunctionPointer(initGameAddress, typeof(InitGame));
                }

                var closeGameAddress = WindowsUtilities.GetProcAddress(dllHandle, "CloseGame");
                if (closeGameAddress != IntPtr.Zero)
                {
                    closeGame = (CloseGame)Marshal.GetDelegateForFunctionPointer(closeGameAddress, typeof(CloseGame));
                }

                var setUserHWndAddress = WindowsUtilities.GetProcAddress(dllHandle, "SetUserHWND");
                if (setUserHWndAddress != IntPtr.Zero)
                {
                    setUserHWnd =
                        (SetUserHWND)Marshal.GetDelegateForFunctionPointer(setUserHWndAddress, typeof(SetUserHWND));
                }

                var executeCmdAddress = WindowsUtilities.GetProcAddress(dllHandle, "ExecuteCommand");
                if (executeCmdAddress != IntPtr.Zero)
                {
                    executeCmd =
                        (ExecuteCommand)
                        Marshal.GetDelegateForFunctionPointer(executeCmdAddress, typeof(ExecuteCommand));
                }

                var getHoveredNPCInfoAddress = WindowsUtilities.GetProcAddress(dllHandle, "GetHoveredNPCInfo");
                if (getHoveredNPCInfoAddress != IntPtr.Zero)
                {
                    getHoveredNPCInfo =
                        (GetHoveredNPCInfo)
                        Marshal.GetDelegateForFunctionPointer(getHoveredNPCInfoAddress, typeof(GetHoveredNPCInfo));
                }

                var getMouseXYZInGameAddress = WindowsUtilities.GetProcAddress(dllHandle, "GetMouseXYZInGame");
                if (getMouseXYZInGameAddress != IntPtr.Zero)
                {
                    getMouseXYZInGame =
                        (GetMouseXYZInGame)
                        Marshal.GetDelegateForFunctionPointer(getMouseXYZInGameAddress, typeof(GetMouseXYZInGame));
                }

                var checkGameDoneAddress = WindowsUtilities.GetProcAddress(dllHandle, "CheckGameDone");
                if (checkGameDoneAddress != IntPtr.Zero)
                {
                    checkIfGameLoaded =
                        (CheckIfGameLoaded)
                        Marshal.GetDelegateForFunctionPointer(checkGameDoneAddress, typeof(CheckIfGameLoaded));
                }

                var detectCollisionAddress = WindowsUtilities.GetProcAddress(dllHandle, "CollisionDetection");
                if (checkGameDoneAddress != IntPtr.Zero)
                {
                    detectCollision =
                        (DetectCollision)
                        Marshal.GetDelegateForFunctionPointer(detectCollisionAddress, typeof(DetectCollision));
                }
            }
        }
        static IconInteractionUtility()
        {
            string hookCostumePath = Path.Combine(Settings.Default.CityOfHeroesGameDirectory, "HookCostume.dll");

            //Shared.Logging.FileLogManager.ForceLog(hookCostumePath);
            dllHandle = WindowsUtilities.LoadLibrary(hookCostumePath);
            if (dllHandle != null)
            {
                IntPtr initGameAddress = WindowsUtilities.GetProcAddress(dllHandle, "InitGame");
                if (initGameAddress != IntPtr.Zero)
                {
                    initGame = (InitGame)(Marshal.GetDelegateForFunctionPointer(initGameAddress, typeof(InitGame)));
                    //Shared.Logging.FileLogManager.ForceLog("Init Game Located");
                }

                IntPtr closeGameAddress = WindowsUtilities.GetProcAddress(dllHandle, "CloseGame");
                if (closeGameAddress != IntPtr.Zero)
                {
                    closeGame = (CloseGame)(Marshal.GetDelegateForFunctionPointer(closeGameAddress, typeof(CloseGame)));
                    //Shared.Logging.FileLogManager.ForceLog("Close Game Located");
                }

                IntPtr setUserHWndAddress = WindowsUtilities.GetProcAddress(dllHandle, "SetUserHWND");
                if (setUserHWndAddress != IntPtr.Zero)
                {
                    setUserHWnd = (SetUserHWND)(Marshal.GetDelegateForFunctionPointer(setUserHWndAddress, typeof(SetUserHWND)));
                    //Shared.Logging.FileLogManager.ForceLog("Set User HWND Located");
                }

                IntPtr executeCmdAddress = WindowsUtilities.GetProcAddress(dllHandle, "ExecuteCommand");
                if (executeCmdAddress != IntPtr.Zero)
                {
                    executeCmd = (ExecuteCommand)(Marshal.GetDelegateForFunctionPointer(executeCmdAddress, typeof(ExecuteCommand)));
                    //Shared.Logging.FileLogManager.ForceLog("Execute Command Located");
                }

                IntPtr getHoveredNPCInfoAddress = WindowsUtilities.GetProcAddress(dllHandle, "GetHoveredNPCInfo");
                if (getHoveredNPCInfoAddress != IntPtr.Zero)
                {
                    getHoveredNPCInfo = (GetHoveredNPCInfo)(Marshal.GetDelegateForFunctionPointer(getHoveredNPCInfoAddress, typeof(GetHoveredNPCInfo)));
                    //Shared.Logging.FileLogManager.ForceLog("Get Hovered NPC Info Located");
                }

                IntPtr getMouseXYZInGameAddress = WindowsUtilities.GetProcAddress(dllHandle, "GetMouseXYZInGame");
                if (getMouseXYZInGameAddress != IntPtr.Zero)
                {
                    getMouseXYZInGame = (GetMouseXYZInGame)(Marshal.GetDelegateForFunctionPointer(getMouseXYZInGameAddress, typeof(GetMouseXYZInGame)));
                    //Shared.Logging.FileLogManager.ForceLog("Get Mouse XYZ Located");
                }

                IntPtr checkGameDoneAddress = WindowsUtilities.GetProcAddress(dllHandle, "CheckGameDone");
                if (checkGameDoneAddress != IntPtr.Zero)
                {
                    checkIfGameLoaded = (CheckIfGameLoaded)(Marshal.GetDelegateForFunctionPointer(checkGameDoneAddress, typeof(CheckIfGameLoaded)));
                    //Shared.Logging.FileLogManager.ForceLog("Check Game Done Located");
                }

                IntPtr detectCollisionAddress = WindowsUtilities.GetProcAddress(dllHandle, "CollisionDetection");
                if (detectCollisionAddress != IntPtr.Zero)
                {
                    detectCollision = (DetectCollision)(Marshal.GetDelegateForFunctionPointer(detectCollisionAddress, typeof(DetectCollision)));
                    //Shared.Logging.FileLogManager.ForceLog("Collision Detection Located");
                }
            }
        }
コード例 #7
0
 public void turnToTargetDirection(Statistics statistics, DetectCollision collision)
 {
     statistics.LookAtPoint = collision.getTargetPosition();
 }
コード例 #8
0
 // Start is called before the first frame update
 void Start()
 {
     detectCollisionScript = GameObject.Find("Coins").GetComponent <DetectCollision>();
 }
コード例 #9
0
    // Use this for initialization
    void Start()
    {
//		Debug.Log ("Newly start!");
        //		setMoverioController ();

        GameObject wrenchFittingObject = GameObject.FindWithTag("WrenchFitting");

        if (wrenchFittingObject != null)
        {
            wireframe_renderer = wrenchFittingObject.GetComponent <MeshRenderer> ();
        }

        standard_shader  = Shader.Find("Standard");
        wireframe_shader = Shader.Find("Digicrafts/Wireframe/Unlit/Transparent Cutout");


        start_vibration_coroutine = startVibration();
        stop_vibration_coroutine  = stopVibration();

        if (haptic)
        {
            hapticFeedback = true;
        }
        else
        {
            hapticFeedback = false;
        }

        time_record [2 * (round_index - 1)] = System.DateTime.Now;
//		Debug.Log (System.DateTime.Now);


        Debug.Log("round_index: " + round_index);

        OscDataReceiver.Instance.setChangeSmoothPos(changeSmoothPos);

//		GameObject drillCombinationObject = GameObject.FindWithTag ("DrillCombination");
//		if (drillCombinationObject != null) {
//			drillCombinationController_placementAroundACircle = drillCombinationObject.GetComponent<PlacementAroundACircle> ();
//			drillCombinationController_placementAroundACircle.setRadius (radius);
//
//			drillCombinationController_simplePositionMovement = drillCombinationObject.GetComponent<SimplePositionMovement> ();
//			drillCombinationController_simplePositionMovement.setReference (localReference);
//		} else {
//			if (openOutput) {
//				Debug.Log ("GameController: can not find drillCombinationController_circle");
//			}
//		}

        GameObject handleObject = GameObject.FindWithTag("Handle");

        if (handleObject != null)
        {
            handleController_simplePositionMovement = handleObject.GetComponent <SimplePositionMovement> ();
            handleController_simplePositionMovement.setReference(localReference);
        }
        else
        {
            if (openOutput)
            {
                Debug.Log("GameController: can not find handleController_simplePositionMovement");
            }
        }

        GameObject triggerObject = GameObject.FindWithTag("Trigger");

        if (triggerObject != null)
        {
            triggerController = triggerObject.GetComponent <TwoAngleRotation> ();

            triggerController.setRotationSpeed(triggerRotationSpeed);
            triggerController.setRotationDiff(triggerRotationDiff);
            triggerController.setRotationAxis(triggerRotationAxis);
        }
        else
        {
            if (openOutput)
            {
                Debug.Log("GameController: can not find triggerController");
            }
        }

        GameObject rotationTriggerObject = GameObject.FindWithTag("RotationTrigger");

        if (rotationTriggerObject != null)
        {
            rotationTriggerController = rotationTriggerObject.GetComponent <TwoPointsMovement> ();

            rotationTriggerController.setMovementSpeed(rotationTriggerMovementSpeed);
            rotationTriggerController.setPosDiff(rotationTriggerPosDiff);
        }
        else
        {
            if (openOutput)
            {
                Debug.Log("GameController: can not find rotationTriggerController");
            }
        }

        GameObject airRegulatorObject = GameObject.FindWithTag("AirRegulator");

        if (airRegulatorObject != null)
        {
            airRegulatorController = airRegulatorObject.GetComponent <FixedAngleRotation> ();

            airRegulatorController.setRotationSpeed(airRegulatorRotationSpeed);
            airRegulatorController.setRotationDiff(airRegulatorRotationDiff);
            airRegulatorController.setRotationAxis(airRegulatorRotationAxis);
        }
        else
        {
            if (openOutput)
            {
                Debug.Log("GameController: can not find airRegulatorController");
            }
        }

        GameObject drillBitObject = GameObject.FindWithTag("DrillBit");

        if (drillBitObject != null)
        {
            drillBitController = drillBitObject.GetComponent <Rotation> ();
            drillBitController.setRotationAxis(drillBitRotationAxis);
        }
        else
        {
            if (openOutput)
            {
                Debug.Log("GameController: can not find drillBitController");
            }
        }

        for (int i = 0; i < subtask_cnt; i++)
        {
            GameObject flangeNutObject = GameObject.FindWithTag(flangenut_tags [i]);
            if (flangeNutObject != null)
            {
                flangeNut_Rotation [i] = flangeNutObject.GetComponent <flangeNutRotation> ();
                flangeNut_Rotation [i].setRotationAxis(drillBitRotationAxis);
            }
            else
            {
                if (openOutput)
                {
                    Debug.Log("GameController: can not find flangeNut_Rotation " + i);
                }
            }
            if (flangeNutObject != null)
            {
                FlangeNut_simplePositionMovement [i] = flangeNutObject.GetComponent <flangeNutSimplePositionMovement> ();
                FlangeNut_simplePositionMovement [i].setReference(localReference);
            }
            else
            {
                if (openOutput)
                {
                    Debug.Log("GameController: can not find FlangeNut_simplePositionMovement " + i);
                }
            }
        }

        wrenchFittingObject = GameObject.FindWithTag("WrenchFitting");
        if (wrenchFittingObject != null)
        {
            wrenchFittingController = wrenchFittingObject.GetComponent <DetectCollision> ();
        }
        else
        {
            if (openOutput)
            {
                Debug.Log("GameController: can not find wrenchFittingController");
            }
        }

        if (OSCControl)
        {
            GameObject OSCDataReceiverObject = GameObject.FindWithTag("OSCDataReceiver");
            if (OSCDataReceiverObject != null)
            {
                OSCDataReceiverController = OSCDataReceiverObject.GetComponent <OscDataReceiver> ();
            }
        }

        GameObject OSCDataSenderObject = GameObject.FindWithTag("OSCDataSender");

        if (OSCDataSenderObject != null)
        {
            OSCDataSenderController = OSCDataSenderObject.GetComponent <OscDataSender> ();
        }


        for (int i = 0; i < subtask_cnt; i++)
        {
            GameObject FlangeNutStateObject = GameObject.FindWithTag("flangenut_" + (char)(i + '0'));
            if (FlangeNutStateObject != null)
            {
                FlangeNutStateController [i] = FlangeNutStateObject.GetComponent <FlangeNutState> ();
            }
            else
            {
                Debug.Log("flangeNutRotation: can not find FlangeNutStateController " + (char)(i + '0'));
            }
        }


        GameObject GameControllerObject = GameObject.FindWithTag("GameController");

        if (GameControllerObject != null)
        {
            OutputSystemController = GameControllerObject.GetComponent <OutputSystem> ();
            Debug.Log("GameController: Set OutputSystem!");
        }
        else
        {
            Debug.Log("GameController: Can not find OutputSystem!");
        }


        for (int i = 0; i < subtask_cnt; i++)
        {
            string tmp = "arrow_indicator_" + (char)(i + '0');
            Debug.Log(tmp);
            current_arrow_indicator [i] = GameObject.FindWithTag(tmp);
        }


        GameObject SceneParameterManagerControllerObject = GameObject.FindWithTag("SceneParameterManager");

        if (SceneParameterManagerControllerObject != null)
        {
            SceneParameterManagerController = SceneParameterManagerControllerObject.GetComponent <SceneParameterManager> ();
        }
        else
        {
            Debug.Log("GameController: Can not find SceneParameterManager!");
        }


        GameObject soundManagerControllerObject = GameObject.FindWithTag("SoundManager");

        if (soundManagerControllerObject != null)
        {
            soundManagerController = soundManagerControllerObject.GetComponent <SoundManager> ();
        }
        else
        {
            Debug.Log("GameController: Can not find SoundManager!");
        }

        _2DCamera = GameObject.FindWithTag("2DCamera");
//		if (cameraObject != null) {
//			_2DCamera = cameraObject.GetComponent<Camera> ();
//		} else {
//			Debug.Log ("_2DCamer: Can not find 2DCamera!");
//		}


        if (!randomize_order)
        {
            subtask_order = subtask_order_array [0];
        }
        else
        {
            int rand = Random.Range(1, subtask_order_array.GetLength(0));

//			Debug.Log ("subtask_order_array.GetLength (0): " + subtask_order_array.GetLength (0));
//			Debug.Log ("rand: " + rand);

            subtask_order = subtask_order_array [rand];
        }

//		Debug.Log ("subtask_order: " + subtask_order);
    }
コード例 #10
0
 // Start is called before the first frame update
 void Start()
 {
     _renderer        = GetComponentInChildren <SpriteRenderer>();
     _detectCollision = GetComponent <DetectCollision>();
 }