Example #1
0
    // Use this for initialization
    void Start()
    {
        PC           = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();
        lookRotation = PC.GetComponent <LookRotation>();

        mouse = new MouseCursor();
        mouse.Hide();
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        playerController = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerControllerFinal>();
        lookRotation     = playerController.GetComponent <LookRotation>(); //It remembers that player controller is that object so it gets a diferent component from the same object.

        mouse = new MouseCursor();
        mouse.Hide();
        gameManager = GetComponent <GameManager>();
    }
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        var data = new LookRotation
        {
            constrainX = constrainX ? 1 : 0,
            constrainY = constrainY ? 1 : 0,
            constrainZ = constrainZ ? 1 : 0,
        };

        dstManager.AddComponentData(entity, data);
    }
Example #4
0
 // Start is called before the first frame update
 void Start()
 {
     playerController = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();
     gun           = playerController.GetComponent <Gun>();
     cameraManager = GameObject.FindGameObjectWithTag("Manager").GetComponent <CameraManager>();
     lookRotation  = playerController.GetComponent <LookRotation>();
     pointing      = false;
     firstPerson   = false;
     canWalk       = true;
     canShot       = true;
     HideCursor();
 }
Example #5
0
    // Use this for initialization
    void Start()
    {
        facing       = gameObject.AddComponent <Facing>();
        basicFollow  = transform.GetComponentInChildren <BasicFollow>();
        basicSearch  = transform.GetComponentInChildren <BasicSearch>();
        lookRotation = transform.GetComponentInChildren <LookRotation>();
        visionRange  = transform.GetComponentInChildren <VisionRange>();
        navMeshAgent = transform.GetComponentInChildren <NavMeshAgent>();

        if (target != null)
        {
            visionRange.validTargets = new List <GameObject> {
                target
            };
        }
    }
Example #6
0
        private static bool ApplyRotation(NeckLookControllerVer2 __instance)
        {
            if (POVEnabled)
            {
                if (!currentChara)
                {
                    POVEnabled = false;
                    return(true);
                }

                Vector3 rot;
                if (LookRotation.TryGetValue(currentCharaGo, out var val))
                {
                    rot = val;
                }
                else
                {
                    LookRotation[currentCharaGo] = rot = currentChara.objHeadBone.transform.rotation.eulerAngles;
                }

                if (__instance.neckLookScript && currentChara.neckLookCtrl == __instance)
                {
                    __instance.neckLookScript.aBones[0].neckBone.rotation = Quaternion.identity;
                    __instance.neckLookScript.aBones[1].neckBone.rotation = Quaternion.identity;
                    __instance.neckLookScript.aBones[1].neckBone.Rotate(rot);

                    var eyeObjs = currentChara.eyeLookCtrl.eyeLookScript.eyeObjs;
                    GameCamera.transform.position = Vector3.Lerp(eyeObjs[0].eyeTransform.position, eyeObjs[1].eyeTransform.position, 0.5f);
                    GameCamera.transform.rotation = currentChara.objHeadBone.transform.rotation;
                    GameCamera.transform.Translate(Vector3.forward * ViewOffset.Value);
                    GameCamera.fieldOfView = CurrentFOV.Value;

                    return(false);
                }
            }

            return(true);
        }
    // Use this for initialization
    void Start()
    {
        fireProjectile = GetComponent <FireProjectile>();

        fireProjectileCooldown = gameObject.AddComponent <ActionCoolDown>();
        fireProjectileCooldown.cooldownTime = fireProjectileCooldownTime;

        facing       = gameObject.AddComponent <Facing>();
        basicPatrol  = transform.GetComponentInChildren <BasicPatrol>();
        basicSearch  = transform.GetComponentInChildren <BasicSearch>();
        lookRotation = transform.GetComponentInChildren <LookRotation>();
        visionRange  = transform.GetComponentInChildren <VisionRange>();
        navMeshAgent = transform.GetComponentInChildren <NavMeshAgent>();

        health = transform.GetComponentInChildren <Health>();

        if (target != null)
        {
            visionRange.validTargets = new List <GameObject> {
                target
            };
        }
    }
    public void SpawnPlayer(int playerNumber, bool recreateGameObject = true)
    {
        if (recreateGameObject == false)
        {
            switch (playerNumber)
            {
            case 1:
                players[playerNumber - 1].GetComponentInChildren <PlayerController>().transform.position = player1Spawn.position;
                break;

            case 2:
                players[playerNumber - 1].GetComponentInChildren <PlayerController>().transform.position = player2Spawn.position;
                break;

            case 3:
                players[playerNumber - 1].GetComponentInChildren <PlayerController>().transform.position = player3Spawn.position;
                break;

            case 4:
                players[playerNumber - 1].GetComponentInChildren <PlayerController>().transform.position = player4Spawn.position;
                break;

            default:
                break;
            }

            return;
        }

        // If we have a player in that spot, delete it
        if (players[playerNumber - 1] != null)
        {
            Destroy(players[playerNumber - 1]);
            players[playerNumber - 1] = null;
        }

        GameObject newPlayer = null;

        // Switch on the different players to spawn them in different spots
        switch (playerNumber)
        {
        case 1:
            newPlayer = Instantiate(playerPrefab, player1Spawn.position, player1Spawn.rotation) as GameObject;
            break;

        case 2:
            newPlayer = Instantiate(playerPrefab, player2Spawn.position, player2Spawn.rotation) as GameObject;
            break;

        case 3:
            newPlayer = Instantiate(playerPrefab, player3Spawn.position, player3Spawn.rotation) as GameObject;
            break;

        case 4:
            newPlayer = Instantiate(playerPrefab, player4Spawn.position, player4Spawn.rotation) as GameObject;
            break;

        default:
            break;
        }

        // Set the gameObject name
        newPlayer.name = "Player " + playerNumber.ToString();

        // Add to the player array in the correct spot
        players[playerNumber - 1] = newPlayer;

        PlayerController newPlayerController = newPlayer.GetComponentInChildren <PlayerController>();

        // Set each players number
        newPlayerController.playerNumber = playerNumber;
        // Set the controller number
        newPlayerController.controller = (XboxCtrlrInput.XboxController)playerNumber;
        // Set player as alive
        newPlayerController.isAlive = true;

        LookRotation newLookRotation = newPlayer.GetComponentInChildren <LookRotation>();

        newLookRotation.StartUp();
        newLookRotation.LookTowards(Vector3.back * 1000);

        playerColourPicker.SetUp(players);
    }
Example #9
0
    void RespawnPlayer(int playerNumber)
    {
        if (players[playerNumber - 1] != null)
        {
            if (zoneManager.zonePosition == ZoneManager.ZonePosition.Centre)                           // If the zone is in the centre
            {
                players[playerNumber - 1].transform.position = outerSpawns[playerNumber - 1].position; // Spawn on outer spawn
            }
            else
            {
                players[playerNumber - 1].transform.position = centreSpawns[playerNumber - 1].position; // Spawn in the centre
            }

            //// Switch on the different players to spawn them in respective spots
            //switch (playerNumber)
            //{
            //    case 1:
            //        players[playerNumber - 1].transform.position = player1Spawn.position;
            //        break;
            //    case 2:
            //        players[playerNumber - 1].transform.position = player2Spawn.position;
            //        break;
            //    case 3:
            //        players[playerNumber - 1].transform.position = player3Spawn.position;
            //        break;
            //    case 4:
            //        players[playerNumber - 1].transform.position = player4Spawn.position;
            //        break;
            //    default:
            //        break;
            //}

            // Set player as alive
            players[playerNumber - 1].GetComponent <PlayerController>().isAlive = true;

            players[playerNumber - 1].GetComponent <Rigidbody>().velocity = Vector3.zero;

            LookRotation lookRotation = players[playerNumber - 1].transform.parent.GetComponentInChildren <LookRotation>();
            lookRotation.LookTowards(zone.transform.position);
        }

        //// Set the gameObject name
        //newPlayer.name = "Player " + playerNumber.ToString();

        //// Add to the player array in the correct spot
        //players[playerNumber - 1] = newPlayer;

        //PlayerController newPlayerController = newPlayer.GetComponentInChildren<PlayerController>();
        //// Set each players number
        //newPlayerController.playerNumber = playerNumber;
        //// Set the controller number
        //newPlayerController.controller = (XboxCtrlrInput.XboxController)playerNumber;
        //// Set player as alive
        //newPlayerController.isAlive = true;

        //LookRotation newLookRotation = newPlayer.GetComponentInChildren<LookRotation>();
        //newLookRotation.StartUp();
        //newLookRotation.LookTowards(zone.transform.position);

        ////TODO do this is a better spot or a better way
        //playerColourPicker.SetUp(players);
    }
 private void Start()
 {
     lookRotation = transform.GetComponentInChildren <LookRotation>();
     navMeshAgent = transform.GetComponentInChildren <NavMeshAgent>();
 }
Example #11
0
        protected override void EnablePov()
        {
            if (!currentChara)
            {
                if (isStudio)
                {
                    var selectedCharas = GuideObjectManager.Instance.selectObjectKey.Select(x => Studio.Studio.GetCtrlInfo(x) as OCIChar).Where(x => x != null).ToList();
                    if (selectedCharas.Count > 0)
                    {
                        var ociChar = selectedCharas.First();
                        currentChara   = ociChar.charInfo;
                        currentCharaId = ociChar.objectInfo.dicKey;
                        currentCharaGo = currentChara.gameObject;
                    }
                    else
                    {
                        Logger.LogMessage("Select a character in workspace to enter its POV");
                    }
                }
                else
                {
                    Queue <ChaControl> CreateQueue()
                    {
                        return(new Queue <ChaControl>(FindObjectsOfType <ChaControl>()));
                    }

                    ChaControl GetCurrentChara()
                    {
                        for (int i = 0; i < charaQueue.Count; i++)
                        {
                            var chaControl = charaQueue.Dequeue();

                            // Remove destroyed
                            if (!chaControl)
                            {
                                continue;
                            }

                            // Rotate the queue
                            charaQueue.Enqueue(chaControl);
                            if (chaControl.sex == 0 && hFlag && (hFlag.mode == HFlag.EMode.aibu || hFlag.mode == HFlag.EMode.lesbian || hFlag.mode == HFlag.EMode.masturbation))
                            {
                                continue;
                            }
                            // Found a valid character, otherwise skip (needed for story mode H because roam mode characters are in the queue too, just disabled)
                            if (chaControl.objTop.activeInHierarchy)
                            {
                                return(chaControl);
                            }
                        }
                        return(null);
                    }

                    if (charaQueue == null)
                    {
                        charaQueue = CreateQueue();
                    }

                    currentChara = GetCurrentChara();
                    if (!currentChara)
                    {
                        charaQueue   = CreateQueue();
                        currentChara = GetCurrentChara();
                    }

                    currentCharaGo = currentChara?.gameObject;
                }
            }

            if (currentChara)
            {
                prevVisibleHeadAlways = currentChara.fileStatus.visibleHeadAlways;
                if (HideHead.Value)
                {
                    currentChara.fileStatus.visibleHeadAlways = false;
                }

                GameCamera = Camera.main;
                var cc = (MonoBehaviour)GameCamera.GetComponent <CameraControl_Ver2>() ?? GameCamera.GetComponent <Studio.CameraControl>();
                if (cc)
                {
                    cc.enabled = false;
                }

                // Fix depth of field being completely out of focus
                var depthOfField = GameCamera.GetComponent <UnityStandardAssets.ImageEffects.DepthOfField>();
                dofOrigSize      = depthOfField.focalSize;
                dofOrigAperature = depthOfField.aperture;
                if (depthOfField.enabled)
                {
                    depthOfField.focalTransform.localPosition = new Vector3(0, 0, 0.25f);
                    depthOfField.focalSize = 0.9f;
                    depthOfField.aperture  = 0.6f;
                }

                // only use head rotation if there is no existing rotation
                if (!LookRotation.TryGetValue(currentCharaGo, out _))
                {
                    LookRotation[currentCharaGo] = currentChara.objHeadBone.transform.rotation.eulerAngles;
                }
                else
                {
                    // always get z axis from head
                    var rot = LookRotation[currentCharaGo];
                    LookRotation[currentCharaGo] = new Vector3(rot.x, rot.y, currentChara.objHeadBone.transform.rotation.eulerAngles.z);
                }

                base.EnablePov();

                backupLayer = GameCamera.gameObject.layer;
                GameCamera.gameObject.layer = 0;
            }
        }
Example #12
0
 private static void ResetAllRotations()
 {
     LookRotation.Clear();
 }