public override void Interaction(ObjectInteractionController oicCaller, Collider other)
    {
        if (other.tag == Tags.player)
        {
            SplinePlayerCharacterController otherPcc = other.transform.GetComponent <SplinePlayerCharacterController>();
            bool isHidden = otherPcc.currPlayerStatus[PlayerCharacterController.StatusListElement.HIDDEN];
            if (!isHidden)
            {
                otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.ROOTED, true);
                otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.HIDDEN, true);
                //TpPlayerOut(hidePosition.position, otherPcc.transform.rotation, otherPcc);

                SoundManager.GetAudio(audioTPID).Play();
                GameObject.Instantiate(Resources.Load("Prefabs/TPCloud"), pcc.transform.position, pcc.transform.rotation);
                otherPcc.transform.SetPositionAndRotation(hidePosition.position, otherPcc.transform.rotation);
            }
            else
            {
                otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.HIDDEN, false);
                otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.ROOTED, false);
                otherPcc.progress = otherPcc.lSpline.GetNearestProgressOnSpline(this.transform.position);

                //TpPlayerOut(otherPcc.lSpline.GetNearestPointOnSpline(this.transform.position), otherPcc.transform.rotation, otherPcc);


                SoundManager.GetAudio(audioTPID).Play();
                GameObject.Instantiate(Resources.Load("Prefabs/TPCloud"), pcc.transform.position, pcc.transform.rotation);
                otherPcc.Move(otherPcc.transform.forward);
            }
        }
    }
示例#2
0
    private void LevelSetupDoor(ref GameData gdd)
    {
        GameObject player = GameObject.FindGameObjectWithTag(Tags.player);
        SplinePlayerCharacterController spcc = player.GetComponent <SplinePlayerCharacterController>();

        SetUpSPCC(spcc, ref gdd);

        if (spcc != null)
        {
            SplineLine   spline    = spcc.lSpline;
            GameObject[] resGOList = GameObject.FindGameObjectsWithTag(Tags.respawn);
            foreach (GameObject go in resGOList)
            {
                ToiletInteractionController tIntCont = go.GetComponent <ToiletInteractionController>();
                if (tIntCont != null)
                {
                    if (tIntCont.toiletNum == gdd.toiletNum)
                    {
                        PositionPlayer(tIntCont.transform, spcc);
                        SplineCameraController mCC = Camera.main.GetComponent <SplineCameraController>();
                        if (mCC != null)
                        {
                            mCC.currCameraPos = tIntCont.nextCameraPosition;
                        }
                    }
                }
            }
        }
        gdd = null;
    }
    private void PrivModifiedMove(Vector3 direction, ObjectInteractionController oicCaller, Collider other)
    {
        SplinePlayerCharacterController otherPcc = other.transform.GetComponent <SplinePlayerCharacterController>();
        float dotMagnitude = Vector3.Dot(deskSpline.transform.TransformVector(deskSpline.GetDirection(deskProgress).normalized), direction);

        if (!otherPcc.currPlayerStatus[PlayerCharacterController.StatusListElement.ROOTED])
        {
            if (Math.Abs(dotMagnitude) > 0.05f)
            {
                deskProgress = deskSpline.GetLengthAtDistFromParametric(Math.Sign(dotMagnitude) * otherPcc.charSpeed * Time.deltaTime, deskProgress);
                Vector3 newPosition = deskSpline.GetPoint(deskProgress);

                Quaternion targetRotation = Quaternion.LookRotation(Math.Sign(dotMagnitude) * deskSpline.transform.TransformVector(deskSpline.GetDirection(deskProgress).normalized), Vector3.up);
                Quaternion newRotation    = Quaternion.Lerp(otherPcc.pcc_rigidbody.rotation, targetRotation, otherPcc.turnSmooth);

                otherPcc.transform.SetPositionAndRotation(newPosition, newRotation);

                otherPcc.pcc_animator.SetFloat("Speed", 5.7f, otherPcc.speedDamptime, Time.deltaTime);
            }
            else
            {
                otherPcc.pcc_animator.SetFloat("Speed", 0f, otherPcc.speedDamptime, Time.deltaTime);
            }
        }
        else
        {
            if (Math.Abs(dotMagnitude) > 0.05f)
            {
                otherPcc.transform.rotation = Quaternion.LookRotation(Math.Sign(dotMagnitude) * deskSpline.GetDirection(deskProgress).normalized, Vector3.up);
                otherPcc.pcc_animator.SetFloat("Speed", 0f, otherPcc.speedDamptime, Time.deltaTime);
            }
        }
    }
    private void OnSceneGUI()
    {
        spcc = target as SplinePlayerCharacterController;

        Handles.color = Color.yellow;
        Vector3 centerVect = spcc.transform.position + new Vector3(0, 1, 0);

        Handles.DrawLine(centerVect, centerVect + spcc.transform.forward);
    }
示例#5
0
    private void LevelSetupChangeFLoor(ref ChangeFloorData gfc)
    {
        GameObject player = GameObject.FindGameObjectWithTag(Tags.player);
        SplinePlayerCharacterController spcc = player.GetComponent <SplinePlayerCharacterController>();

        if (gd_currentLevel == null)
        {
            gd_currentLevel = SaveManager.LoadFile(saveName);
        }
        if (spcc.currPlayerObjectStatus[Dictionaries.ItemName.SCREWDRIVER] || gd_currentLevel.isScrewUnlocked || (gd_nextLevel != null && gd_nextLevel.isScrewUnlocked))
        {
            spcc.currPlayerObjectStatus[Dictionaries.ItemName.SCREWDRIVER] = true;
            if (gd_currentLevel != null)
            {
                gd_currentLevel.isScrewUnlocked = true;
                SaveManager.Save(gd_currentLevel, saveName);
            }
            if (gd_nextLevel != null)
            {
                gd_nextLevel.isScrewUnlocked = true;
            }
        }
        SetUpSPCC(spcc, ref gd_currentLevel);

        if (gfc != null)
        {
            ChangeFloorInteractionController[] cficList = GameObject.FindObjectsOfType <ChangeFloorInteractionController>();
            if (cficList.Length > 0)
            {
                ChangeFloorInteractionController correctCFIC = null;
                foreach (ChangeFloorInteractionController curCFIC in cficList)
                {
                    if (curCFIC.floorDoorNum == gfc.floorDoorNum)
                    {
                        correctCFIC = curCFIC;
                    }
                }

                if (correctCFIC != null)
                {
                    PositionPlayer(correctCFIC.transform, spcc);
                    SplineCameraController mCC = Camera.main.GetComponent <SplineCameraController>();
                    if (mCC != null)
                    {
                        mCC.currCameraPos = correctCFIC.nextCameraPosition;
                    }
                    spcc.ChangeStatus(PlayerCharacterController.StatusListElement.NINJA, gfc.isNinja);
                }
                else
                {
                    Debug.LogError("Correct CFIC not Found");
                }
            }
        }

        gfc = null;
    }
    private void Awake()
    {
        if (Camera.main != null)
        {
            pic_CamTrans = Camera.main.transform;
        }

        pic_charContr = GetComponent <SplinePlayerCharacterController>();

        pauseController = PauseController.instance;
    }
    private void PrivModifiedMove(Vector3 direction, ObjectInteractionController oicCaller, Collider other)
    {
        SplinePlayerCharacterController otherPcc = other.transform.GetComponent <SplinePlayerCharacterController>();
        float dotMagnitude = Vector3.Dot(plantSpline.transform.TransformVector(plantSpline.GetDirection(plantProgress).normalized), direction);

        if (!otherPcc.currPlayerStatus[PlayerCharacterController.StatusListElement.ROOTED])
        {
            if (Math.Abs(dotMagnitude) > 0.05f)
            {
                // Lerp-Rotate the rigidbody toward the direction

                //Debug.Log(Time.timeSinceLevelLoad+" - SplineDir " + plantSpline.GetDirection(plantProgress).normalized
                //          +"playerDir"+ direction);

                //plantProgress = plantSpline.GetLengthAtDistFromParametric(Math.Sign(dotMagnitude) * otherPcc.charSpeed * Time.deltaTime, plantProgress);
                //Vector3 newPosition = plantSpline.GetPoint(plantProgress);

                //Quaternion targetRotation = Quaternion.LookRotation(Math.Sign(dotMagnitude) * plantSpline.GetDirection(plantProgress).normalized, Vector3.up);
                //Quaternion newRotation = Quaternion.Lerp(otherPcc.pcc_rigidbody.rotation, targetRotation, otherPcc.turnSmooth);

                //transform.SetPositionAndRotation(newPosition, newRotation);


                //otherPcc.pcc_animator.SetFloat("Speed", 4.5f, otherPcc.speedDamptime, Time.deltaTime);

                plantProgress = plantSpline.GetLengthAtDistFromParametric(Math.Sign(dotMagnitude) * otherPcc.charSpeed * Time.deltaTime, plantProgress);
                Vector3 newPosition = plantSpline.GetPoint(plantProgress);

                Quaternion targetRotation = Quaternion.LookRotation(Math.Sign(dotMagnitude) * plantSpline.transform.TransformVector(plantSpline.GetDirection(plantProgress).normalized), Vector3.up);
                Quaternion newRotation    = Quaternion.Lerp(otherPcc.pcc_rigidbody.rotation, targetRotation, otherPcc.turnSmooth);

                otherPcc.transform.SetPositionAndRotation(newPosition, newRotation);


                transform.position = otherPcc.transform.position + (this.transform.position - hidePosition.position);


                //otherPcc.pcc_animator.SetFloat("Speed", 5.7f, otherPcc.speedDamptime, Time.deltaTime);
                otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.HIDDEN, false);
            }
            else
            {
                otherPcc.pcc_animator.SetFloat("Speed", 0f, otherPcc.speedDamptime, Time.deltaTime);
            }
        }
        else
        {
            if (Math.Abs(dotMagnitude) > 0.05f)
            {
                otherPcc.transform.rotation = Quaternion.LookRotation(Math.Sign(dotMagnitude) * plantSpline.GetDirection(plantProgress).normalized, Vector3.up);
                otherPcc.pcc_animator.SetFloat("Speed", 0f, otherPcc.speedDamptime, Time.deltaTime);
            }
        }
    }
示例#8
0
    public override bool Evaluate(AI_BehaviorBrain brain)
    {
        //\\ METHOD RAYCASTING
        //RaycastHit[] rayCastHits;
        //rayCastHits = Physics.SphereCastAll(brain.transform.position+ height*brain.transform.up, watchSphereRadius, brain.transform.forward, watchRange);
        ////Gizmos.DrawRay(brain.transform.position + height * brain.transform.up, brain.transform.forward);
        //foreach (RaycastHit rayCastHit in rayCastHits)
        //{
        //    if (gameObjectToWatchFor.tag.Equals(rayCastHit.transform.gameObject.tag))
        //    {
        //        return true;
        //    }
        //}
        //return false;

        //\\ METHOD SIGHT CONE
        gameObjectToWatchFor = GameObject.FindGameObjectsWithTag(tag)[0];
        SplinePlayerCharacterController spcc = gameObjectToWatchFor.GetComponent <SplinePlayerCharacterController>();

        if ((!isNinjaOnly && !isSalarymanOnly) ||
            (isNinjaOnly && spcc.currPlayerStatus[PlayerCharacterController.StatusListElement.NINJA]) ||
            (isSalarymanOnly && !spcc.currPlayerStatus[PlayerCharacterController.StatusListElement.NINJA]))
        {
            if (!spcc.currPlayerStatus[statusHIDDEN])
            {
                Vector3 gORelatPos = gameObjectToWatchFor.transform.position - brain.transform.position;
                //Debug.Log("gameObjectToWatchFor" + gameObjectToWatchFor.transform.position);
                if (gORelatPos.magnitude < watchRange)
                {
                    Vector3 frwdVect = brain.transform.forward;
                    float   angle    = Vector3.Angle(frwdVect, gORelatPos);
                    //Debug.Log(brain.gameObject.name + "Player (angle: "+angle+" ) Found at " + brain.currentState.ToString());
                    if (angle < watchRadius)
                    {
                        if (setIsDetected && (spcc.dectectionCd < Time.timeSinceLevelLoad - spcc.lastDectectionTime))
                        {
                            spcc.lastDectectionTime = Time.timeSinceLevelLoad;
                            gameObjectToWatchFor.GetComponent <PlayerCharacterController>().ChangeStatus(PlayerCharacterController.StatusListElement.BLOCKED, true);
                            gameObjectToWatchFor.GetComponent <PlayerCharacterController>().ChangeStatus(PlayerCharacterController.StatusListElement.DETECTED, true);
                        }
                        return(true);
                    }
                }
            }
        }

        return(false);

        //\\ METHODE SPRITE WITH COLLIDER
    }
示例#9
0
    public override void Act(AI_BehaviorBrain brain)
    {
        spcc = GameObject.FindGameObjectWithTag(Tags.player).GetComponent <SplinePlayerCharacterController>();
        if (spcc.currPlayerStatus[PlayerCharacterController.StatusListElement.GAMEOVER] != true)
        {
            spcc.currPlayerStatus[PlayerCharacterController.StatusListElement.GAMEOVER] = true;
            spcc.currPlayerStatus[PlayerCharacterController.StatusListElement.ROOTED]   = true;
            FadeInOutController.instance.FadeIn(() =>
            {
                GameMasterManager.instance.Restart(brain);
            }, fadeInDuration, text);
        }

        //GameMasterManager.Instance.Restart(brain);
    }
示例#10
0
    public override void Interaction(ObjectInteractionController oicCaller, Collider other)
    {
        SplinePlayerCharacterController spcc = other.GetComponent <SplinePlayerCharacterController>();

        GameMasterManager.instance.cfd_nextLevel = new ChangeFloorData(nextfloorDoorNum, spcc.currPlayerStatus[PlayerCharacterController.StatusListElement.NINJA], nextCameraPosition);
        if (nextSceneName != null)
        {
            FadeInOutController.instance.FadeOut(1.0f, "chargement");
            SceneManager.LoadScene(nextSceneName);
        }
        else
        {
            Debug.LogError("Missing Scene Name");
        }
    }
 protected override void ModifiedMove(Vector3 direction, ObjectInteractionController oicCaller, Collider other)
 {
     if (other.tag == Tags.player)
     {
         SplinePlayerCharacterController otherPcc = other.transform.GetComponent <SplinePlayerCharacterController>();
         bool isBehindPot = otherPcc.currPlayerStatus[PlayerCharacterController.StatusListElement.BEHINDPOT];
         if (isBehindPot)
         {
             PrivModifiedMove(direction, oicCaller, other);
         }
         else
         {
             otherPcc.ImplementedMove(direction);
         }
     }
 }
    private void UseVentialtion(ObjectInteractionController oicCaller, Collider other)
    {
        spcc = other.GetComponent <SplinePlayerCharacterController>();
        if (!pcc.currPlayerStatus[PlayerCharacterController.StatusListElement.BLOCKED])
        {
            pcc.ChangeStatus(PlayerCharacterController.StatusListElement.BLOCKED, true);
            PlayerUnitytoSpineController pUSC = StateMachineBehaviourUtilities.GetBehaviourByName <PlayerUnitytoSpineController>(pcc.pcc_animator, "Screwdriver");

            pUSC.onStateExitCallbacks.Add(() =>
            {
                StartToMoveInVentialtion(oicCaller, other);
                pUSC.onStateExitCallbacks.Clear();
            });
            pcc.pcc_animator.SetTrigger("isUsingScrew");
            SoundManager.GetAudio(audioScrewdriver).Play();
        }
    }
示例#13
0
    private void PositionPlayer(Transform transf, SplinePlayerCharacterController spcc)
    {
        spcc.transform.position = spcc.lSpline.GetNearestPointOnSpline(transf.position);
        spcc.progress           = spcc.lSpline.GetNearestProgressOnSpline(transf.position);
        spcc.transform.rotation = Quaternion.LookRotation(spcc.lSpline.GetDirection(spcc.progress));

        GameObject             player = GameObject.FindGameObjectWithTag(Tags.player);
        SplineCameraController sMCC   = new SplineCameraController
        {
            gO = player
        };

        Vector3    newPos = new Vector3();
        Quaternion newRot = new Quaternion();

        sMCC.MoveCamera(ref newPos, ref newRot);

        Camera.main.transform.position = newPos;
        Camera.main.transform.rotation = newRot;
    }
    public override void Interaction(ObjectInteractionController oicCaller, Collider other)
    {
        if (other.tag == Tags.player)
        {
            SplinePlayerCharacterController otherPcc = other.transform.GetComponent <SplinePlayerCharacterController>();
            bool isHidden = otherPcc.currPlayerStatus[PlayerCharacterController.StatusListElement.HIDDEN];
            if (!isHidden)
            {
                otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.BEHINDPOT, true);
                otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.HIDDEN, true);
                deskProgress = deskSpline.GetNearestProgressOnSpline(otherPcc.transform.position);
                //otherPcc.transform.SetPositionAndRotation(deskSpline.GetNearestPointOnSpline(otherPcc.transform.position),
                //    Quaternion.Euler(deskSpline.transform.TransformVector(deskSpline.GetDirection(deskProgress).normalized)));


                SoundManager.GetAudio(audioTPID).Play();
                GameObject.Instantiate(Resources.Load("Prefabs/TPCloud"), pcc.transform.position, pcc.transform.rotation);

                float dotMagnitude = Vector3.Dot(otherPcc.transform.forward, Camera.main.transform.right);
                //Debug.Log("dotMagnitude:" + dotMagnitude);

                otherPcc.transform.SetPositionAndRotation(deskSpline.GetNearestPointOnSpline(otherPcc.transform.position),
                                                          Quaternion.LookRotation(dotMagnitude * deskSpline.transform.TransformVector(deskSpline.GetDirection(deskProgress).normalized), Vector3.up));
            }
            else
            {
                otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.HIDDEN, false);
                otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.BEHINDPOT, false);
                otherPcc.progress = otherPcc.lSpline.GetNearestProgressOnSpline(otherPcc.transform.position);


                SoundManager.GetAudio(audioTPID).Play();
                GameObject.Instantiate(Resources.Load("Prefabs/TPCloud"), pcc.transform.position, pcc.transform.rotation);

                otherPcc.Move(otherPcc.transform.forward);
            }
        }
    }
 public override void Interaction(ObjectInteractionController oicCaller, Collider other)
 {
     if (other.tag == Tags.player)
     {
         SplinePlayerCharacterController otherPcc = other.transform.GetComponent <SplinePlayerCharacterController>();
         bool isReading = otherPcc.currPlayerStatus[PlayerCharacterController.StatusListElement.READING];
         if (isReading)
         {
             if (textMan.isPaused)
             {
                 textMan.NextTextPart();
             }
             else if (textMan.isFinished)
             {
                 otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.READING, false);
                 otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.ROOTED, false);
                 textMan.textComp.text = "";
                 textMan.gameObject.SetActive(false);
                 //textMan.transform.parent.gameObject.SetActive(false);
             }
             else
             {
                 textMan.ForceText();
             }
         }
         else
         {
             // Start reading
             otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.READING, true);
             otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.ROOTED, true);
             //textMan.textComp.text = text;
             textMan.gameObject.SetActive(true);
             //textMan.transform.parent.gameObject.SetActive(true);
             textMan.TypeText(text);
         }
     }
 }
示例#16
0
 public void SetUpSPCC(SplinePlayerCharacterController spcc, ref GameData gdd)
 {
     spcc.currPlayerObjectStatus[Dictionaries.ItemName.SCREWDRIVER] = gdd.isScrewUnlocked;
     spcc.currPlayerObjectStatus[Dictionaries.ItemName.LAXATIVE]    = gdd.isLaxaUnlocked;
     spcc.ChangeStatus(PlayerCharacterController.StatusListElement.NINJA, gdd.isNinja);
 }