示例#1
0
    IEnumerator IE_StartInteractable()
    {
        scPlayer.ActiveControl(1, false);
        if (playerAnimTime > 0.01f)
        {
            scCam.SetInteractScale(true);
            if (playerAnimKey != "")
            {
                scPlayer.SetAnim(playerAnimKey);
            }
            Vector3 playerPos = scPlayer.transform.position;
            scPlayer.transform.position = new Vector3(transform.position.x + playerXOffset, playerPos.y, playerPos.z);
            yield return(new WaitForSeconds(playerAnimTime));

            scPlayer.SetAnim("idle");
            scCam.SetInteractScale(false);
        }

        if (plotKey != "")
        {
            sc_DialogGod.SetPlotFlag(plotKey, true);
        }

        scPlayer.ActiveControl(1, true);
        yield break;
    }
示例#2
0
    IEnumerator IE_ForcePlayerMove()
    {
        //change the way to determine exit pos
        if (playerTR.position.x > myBorder[3] - 0.1f)
        {
            RaycastHit hit;
            if (Physics.Raycast(playerTR.position - Vector3.right * 0.5f, Vector3.right, out hit, 4, wallMask) && hit.collider.tag != "Dynamic")
            {
                yield break;
            }
            if (Physics.Raycast(playerTR.position + Vector3.right * 0.3f, Vector3.right, out hit, 10, areaMask))
            {
                nowForceMove = true;
                scPlayer.ActiveControl(1, false);
                if (hit.distance > 1f)
                {
                    yield return(StartCoroutine(scPlayer.MoveToPos(new Vector2(playerTR.position.x + 0.8f, playerTR.position.y))));

                    playerTR.Translate(hit.distance - 1f, 0, 0);
                    scPlayer.SnapFloor(2);
                    yield return(StartCoroutine(scPlayer.MoveToPos(new Vector2(hit.point.x + 0.5f, playerTR.position.y))));
                }
                else
                {
                    yield return(StartCoroutine(scPlayer.MoveToPos(new Vector2(hit.point.x + 0.5f, playerTR.position.y))));
                }
            }
        }
        else
        {
            RaycastHit hit;
            if (Physics.Raycast(playerTR.position - Vector3.left * 0.5f, Vector3.left, out hit, 4, wallMask))
            {
                yield break;
            }
            if (Physics.Raycast(playerTR.position + Vector3.left * 0.3f, Vector3.left, out hit, 10, areaMask))
            {
                nowForceMove = true;
                scPlayer.ActiveControl(1, false);
                if (hit.distance > 1.7f)
                {
                    yield return(StartCoroutine(scPlayer.MoveToPos(new Vector2(playerTR.position.x - 0.8f, playerTR.position.y))));

                    playerTR.Translate(-hit.distance + 1f, 0, 0);
                    scPlayer.SnapFloor(2);
                    yield return(StartCoroutine(scPlayer.MoveToPos(new Vector2(hit.point.x - 0.5f, playerTR.position.y))));
                }
                else
                {
                    yield return(StartCoroutine(scPlayer.MoveToPos(new Vector2(hit.point.x - 0.5f, playerTR.position.y))));
                }
            }
        }
        nowForceMove = false;
        scPlayer.ActiveControl(1, true);
    }
示例#3
0
    public void RegTalkingNPC(bool registing, string _npcName, Transform _npcTR)
    {
        if (registing)
        {
            if (!list_talkingNPC.Contains(_npcName))
            {
                list_talkingNPC.Add(_npcName);
            }
            scPlayer.ActiveControl(0, false);
        }
        else
        {
            if (list_talkingNPC.Contains(_npcName))
            {
                list_talkingNPC.Remove(_npcName);
            }
        }

        if (list_talkingNPC.Count == 0)
        {
            hasTalked = true;
            scPlayer.ActiveControl(0, true);
            sc_God.MainCam.scCam.SetFollowTarget(true);
        }
        else if (list_talkingNPC.Count == 1)
        {
            Transform nowNpcTR = NPCs [list_talkingNPC [0]].transform;
            sc_God.MainCam.scCam.SetFollowTarget(playerTR, NPCs [list_talkingNPC [0]].transform, true);
        }
        else if (list_talkingNPC.Count >= 2)
        {
            int       count = list_talkingNPC.Count;
            Transform t0    = NPCs [list_talkingNPC [count - 1]].transform;
            Transform t1    = NPCs [list_talkingNPC [count - 2]].transform;
            sc_God.MainCam.scCam.SetFollowTarget(t0, t1, true);
        }
    }
示例#4
0
    IEnumerator IE_TalkNpcSequence(string[] array_function)
    {
        char[] funcSpliter = new char[] { '(', ',', ')' };

        foreach (string functionUnit in array_function)
        {
            string[] funcVars = functionUnit.Split(funcSpliter, System.StringSplitOptions.RemoveEmptyEntries);
            switch (funcVars [0])
            {
            case "Move":
                yield return(StartCoroutine(MoveToPos(SplitVectorStr(funcVars[1]))));

                break;

            case "Face":
                if (funcVars [1] == "right" || funcVars[1] == "Right")
                {
                    yield return(StartCoroutine(FaceTarget(true)));
                }
                else if (funcVars [1] == "left" || funcVars[1] == "Left")
                {
                    yield return(StartCoroutine(FaceTarget(false)));
                }
                else
                {
                    Transform faceTarget;
                    if (funcVars [1] == "Player")
                    {
                        faceTarget = playerTR;
                    }
                    else
                    {
                        faceTarget = scDialog.scGod.GetNpcDialog(funcVars [1]).transform;
                    }
                    yield return(StartCoroutine(FaceTarget(faceTarget)));
                }
                break;

            case "BoxSide":
                if (funcVars [1] == "Right")
                {
                    scDialog.isRightBox = true;
                }
                else
                {
                    scDialog.isRightBox = false;
                }
                break;

            case "CheckPlayer":
                if (funcVars.Length == 3)
                {
                    yield return(StartCoroutine(CheckPlayer(funcVars [1], float.Parse(funcVars [2]))));
                }
                break;

            case "Wait":
                yield return(new WaitForSeconds(float.Parse(funcVars [1])));

                break;

            case "Fade":
                yield return(StartCoroutine(FadeSprite(float.Parse(funcVars [1]), float.Parse(funcVars [2]))));

                break;

            case "WaitPos":
                Transform waitTarget;
                if (funcVars [1] == "Player")
                {
                    waitTarget = playerTR;
                }
                else if (funcVars [1] == "Self")
                {
                    waitTarget = transform;
                }
                else
                {
                    waitTarget = scDialog.scGod.GetNpcDialog(funcVars [1]).transform;
                }

                yield return(StartCoroutine(WaitPos(waitTarget, SplitVectorStr(funcVars [2]))));

                break;

            case "Teleport":
                if (funcVars.Length == 3 && funcVars [1] == "Player")
                {
                    Transform    targetTR;
                    sc_character targetSC;
                    if (funcVars [1] == "Player")
                    {
                        targetTR = playerTR;
                        targetSC = scPlayer;
                    }
                    else
                    {
                        sc_NpcDialog tmpDial = scDialog.scGod.GetNpcDialog(funcVars [1]);
                        targetTR = tmpDial.transform;
                        targetSC = tmpDial.scTalk;
                    }
                    Vector2 _tmpVec = SplitVectorStr(funcVars [2]);
                    targetTR.position = new Vector3(_tmpVec.x, _tmpVec.y, targetTR.position.z);
                    targetSC.SnapFloor(1f);
                }
                else
                {
                    Vector2 _tmpVec = SplitVectorStr(funcVars [1]);
                    transform.position = new Vector3(_tmpVec.x, _tmpVec.y, transform.position.z);
                    SnapFloor(1f);
                }

                break;

            case "Talk":
                if (funcVars.Length == 1)
                {
                    scDialog.scGod.StartPlot(funcVars[1]);
                }
                break;

            case "Anim":
                SetAnim(funcVars [1]);
                break;

            case "PlayerAnim":
                scPlayer.SetAnim(funcVars [1]);
                break;

            case "CamAnim":
                sc_God.MainCam.scCam.CamAnim(float.Parse(funcVars [1]), SplitVectorStr(funcVars [2]), float.Parse(funcVars [3]));
                break;

            case "CamFocus":
                sc_God.MainCam.scCam.SetFocusBlack(float.Parse(funcVars [1]), float.Parse(funcVars [2]));
                break;

            case "CamFree":
                sc_God.MainCam.scCam.FreeCamera(bool.Parse(funcVars [1]));
                break;

            case "PlayerControl":
                scPlayer.ActiveControl(int.Parse(funcVars [1]), bool.Parse(funcVars [2]));
                break;

            case "Plot":
                sc_DialogGod.SetPlotFlag(funcVars [1], true);
                break;

            case "PlayerEle":
                scPlayer.DoInteractable();
                break;

            case "SetAlpha":
                SetAlpha(float.Parse(funcVars [1]));
                break;

            case "EnableSprite":
                EnableSprite(bool.Parse(funcVars [1]));
                break;
            }
        }
        yield break;
    }