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);
            }
        }
    }
    public void AddAction(ActionListElement actionName, NextAction nextAction, ObjectInteractionController oicCaller, Collider other)
    {
        NextActionStruct NAStructToAdd = new NextActionStruct
        {
            Interaction = nextAction,
            oicCaller   = oicCaller,
            other       = other
        };

        switch (actionName)
        {
        case ActionListElement.HIDE:
            hideActionList.Add(NAStructToAdd);
            break;

        case ActionListElement.INTERACT:
            interactActionList.Add(NAStructToAdd);
            break;

        case ActionListElement.DASH:
            dashActionList.Add(NAStructToAdd);
            break;

        case ActionListElement.USE:
            useActionList.Add(NAStructToAdd);
            break;

        default:
            break;
        }
    }
    public override void Interaction(ObjectInteractionController oicCaller, Collider other)
    {
        GameMasterManager gMM = GameMasterManager.instance;

        switch (itemName)
        {
        case Dictionaries.ItemName.SCREWDRIVER:
            if (!gMM.gd_currentLevel.isScrewUnlocked)
            {
                AddItem(itemName, other);
            }
            RemoveInteraction(other);
            Destroy(gameObject);
            break;

        case Dictionaries.ItemName.LAXATIVE:
            if (!gMM.gd_currentLevel.isLaxaUnlocked)
            {
                AddItem(itemName, other);
            }
            RemoveInteraction(other);
            Destroy(gameObject);
            break;

        default:
            break;
        }
        if (CheckInteractionValidity(other))
        {
            pcc.UpdateObjectStatus();
        }
    }
    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 Start()
 {
     objectInteractionController = FindObjectOfType <ObjectInteractionController>();
     foreach (Transform child in transform)
     {
         childMeshes.Add(child.GetComponent <MeshRenderer>());
     }
     ApplyCubeType();
 }
Exemplo n.º 6
0
 public override void Interaction(ObjectInteractionController oicCaller, Collider other)
 {
     other.GetComponent <SplinePlayerCharacterController>().ChangeStatus(PlayerCharacterController.StatusListElement.BLOCKED, true);
     other.GetComponent <SplinePlayerCharacterController>().ChangeStatus(PlayerCharacterController.StatusListElement.HIDDEN, true);
     FadeInOutController.instance.FadeIn(() =>
     {
         SceneManager.LoadScene(0);
     }, fadeInDuration, text);
 }
    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);
            }
        }
    }
    public void AddMove(MoveAction moveAction, ObjectInteractionController oicCaller, Collider other)
    {
        MoveStruct MStructToAdd = new MoveStruct
        {
            moveAction = moveAction,
            oicCaller  = oicCaller,
            other      = other
        };

        moveList.Add(MStructToAdd);
    }
    // saves current GameData into a save file
    public void SaveGame(WorldManager worldManager, ObjectInteractionController objectInteractionController)
    {
        string path = GetDataPath(saveFileName);

        using (FileStream stream = new FileStream(path, FileMode.Create))
        {
            print("saving to " + path);
            BinaryFormatter formatter = new BinaryFormatter();
            GameData        gameData  = new GameData(worldManager, objectInteractionController);
            formatter.Serialize(stream, gameData);
        }
    }
Exemplo n.º 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);
         }
     }
 }
Exemplo n.º 12
0
 public override void Interaction(ObjectInteractionController oicCaller, Collider other)
 {
     if (other.tag == Tags.player)
     {
         PlayerCharacterController pcc = other.GetComponent <PlayerCharacterController>();
         if (pcc != null)
         {
             pcc.currPlayerStatus[PlayerCharacterController.StatusListElement.ROOTED] = true;
             if (pcc.currPlayerStatus[PlayerCharacterController.StatusListElement.NINJA])
             {
                 FadeInOutController.instance.FadeIn(() =>
                 {
                     TransformToSalaryman(pcc);
                     SplineCameraController mCC = Camera.main.GetComponent <SplineCameraController>();
                     if (mCC != null)
                     {
                         mCC.currCameraPos = nextCameraPosition;
                     }
                     SoundManager.GetAudio(audioToilet).Play();
                     FadeInOutController.instance.FadeOut(() =>
                     {
                         pcc.currPlayerStatus[PlayerCharacterController.StatusListElement.ROOTED] = false;
                         this.SaveGame();
                     }, fadeInDuration, "");
                 }, fadeOutDuration, text);
             }
             else
             {
                 FadeInOutController.instance.FadeIn(() =>
                 {
                     TransformToNinja(pcc);
                     SplineCameraController mCC = Camera.main.GetComponent <SplineCameraController>();
                     if (mCC != null)
                     {
                         mCC.currCameraPos = nextCameraPosition;
                     }
                     SoundManager.GetAudio(audioToilet).Play();
                     FadeInOutController.instance.FadeOut(() =>
                     {
                         pcc.currPlayerStatus[PlayerCharacterController.StatusListElement.ROOTED] = false;
                         this.SaveGame();
                     }, fadeInDuration, "");
                 }, fadeInDuration, text);
             }
         }
     }
 }
    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();
        }
    }
 private void StartToMoveInVentialtion(ObjectInteractionController oicCaller, Collider other)
 {
     SoundManager.GetAudio(audioScrewdriver).Stop();
     if (pcc.currPlayerStatus[PlayerCharacterController.StatusListElement.DETECTED] == false)
     {
         pcc.ChangeStatus(PlayerCharacterController.StatusListElement.HIDDEN, true);
         pcc.ninjaModel.SetActive(false);
         currProgress = startProgress;
         pcc.StartCoroutine(MoveInVentialtion());
         SoundManager.GetAudio(audioVentilation).loop = true;
         SoundManager.GetAudio(audioVentilation).Play();
     }
     else
     {
         pcc.ChangeStatus(PlayerCharacterController.StatusListElement.BLOCKED, false);
     }
 }
    public void RemoveAction(ActionListElement actionName, NextAction nextAction, ObjectInteractionController oicCaller, Collider other)
    {
        List <NextActionStruct> listToRemoveFrom;

        switch (actionName)
        {
        case ActionListElement.HIDE:
            listToRemoveFrom = hideActionList;
            break;

        case ActionListElement.INTERACT:
            listToRemoveFrom = interactActionList;
            break;

        case ActionListElement.DASH:
            listToRemoveFrom = dashActionList;
            break;

        case ActionListElement.USE:
            listToRemoveFrom = useActionList;
            break;

        default:
            listToRemoveFrom = null;
            break;
        }

        if (listToRemoveFrom != null)
        {
            for (int i = 0; i < listToRemoveFrom.Count; i++)
            {
                NextActionStruct currNAS = listToRemoveFrom[i];
                if (oicCaller == currNAS.oicCaller &&
                    other == currNAS.other &&
                    nextAction == currNAS.Interaction)
                {
                    listToRemoveFrom.Remove(currNAS);
                    break;
                }
            }
        }
    }
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.P))
     {
         if (worldManager == null)
         {
             worldManager = FindObjectOfType <WorldManager>();
         }
         objectInteractionController = FindObjectOfType <ObjectInteractionController>();
         savingSystem.SaveGame(worldManager, objectInteractionController);
     }
     if (Input.GetKeyDown(KeyCode.L))
     {
         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
     }
     if (Input.GetKeyDown(KeyCode.Delete))
     {
         savingSystem.DeleteFile();
     }
 }
    // Applies current Cube Type, also calls refresh
    public void ApplyCubeType()
    {
        if (objectInteractionController == null)
        {
            objectInteractionController = FindObjectOfType <ObjectInteractionController>();
        }
        currentCubeType = objectInteractionController.GetCubeType();

        if (currentCubeType == null)
        {
            TargetChanged(); return;
        }
        if (currentCubeType.materials.Length != 6)
        {
            return;
        }
        for (int i = 0; i < 6; i++)
        {
            childMeshes[i].material = currentCubeType.materials[i];
        }
        TargetChanged();
    }
    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 void RemoveMove(MoveAction moveAction, ObjectInteractionController oicCaller, Collider other)
    {
        MoveStruct MStructToAdd = new MoveStruct
        {
            moveAction = moveAction,
            oicCaller  = oicCaller,
            other      = other
        };

        if (moveList != null)
        {
            for (int i = 0; i < moveList.Count; i++)
            {
                if (moveAction == moveList[i].moveAction &&
                    oicCaller == moveList[i].oicCaller &&
                    other == moveList[i].other)
                {
                    moveList.Remove(moveList[i]);
                    break;
                }
            }
        }
    }
 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);
         }
     }
 }
Exemplo n.º 21
0
 protected override void ModifiedMove(Vector3 direction, ObjectInteractionController oicCaller, Collider other)
 {
     throw new System.NotImplementedException();
 }
 protected abstract void ModifiedMove(Vector3 direction, ObjectInteractionController oicCaller, Collider other);
Exemplo n.º 23
0
    public GameData(WorldManager worldManager, ObjectInteractionController objectInteractionController)
    {
        ProcessPlayerData(objectInteractionController);

        ProcessWorldData(worldManager);
    }
Exemplo n.º 24
0
 // stores player's position
 private void ProcessPlayerData(ObjectInteractionController objectInteractionController)
 {
     playerData.playerXPosition = objectInteractionController.transform.position.x;
     playerData.playerYPosition = objectInteractionController.transform.position.y;
     playerData.playerZPosition = objectInteractionController.transform.position.z;
 }
 public override void Interaction(ObjectInteractionController oicCaller, Collider other)
 {
     UseVentialtion(oicCaller, other);
 }
    public override void Interaction(ObjectInteractionController oicCaller, Collider other)
    {
        //string saveName = "Save_001";

        GameMasterManager.instance.Restart(this);
    }
 public abstract void Interaction(ObjectInteractionController oicCaller, Collider other);