示例#1
0
 public void SetSpecialTalk()
 {
     player.Playerstate = Player.PlayerState.talk;
     SaveData.CharsInfo _charInfo = SaveData._data.getCharInfo(itemName);
     if (_charInfo.talkStatus == SaveData.CharsInfo.TalkStatus.firstTalk)
     {
         GameManager.game.SetTalk("yellow", 51);
     }
     else if (_charInfo.talkStatus == SaveData.CharsInfo.TalkStatus.premissionNotComplete)
     {
         GameManager.game.SetTalk("yellow", 52);
     }
     else if (_charInfo.talkStatus == SaveData.CharsInfo.TalkStatus.missionComplete)
     {
         GameManager.game.SetTalk("yellow", 53);
     }
     GameManager.game.Setactive(GameManager.game.TalkUI, true);
 }
示例#2
0
 public void SetTalk()
 {
     player.Playerstate = Player.PlayerState.talk;
     //發送NPC說話事件
     if (OnItemTalked != null)
     {
         OnItemTalked(this, EventArgs.Empty);//分發事件
     }
     //load talk data
     SaveData.CharsInfo _charInfo = new SaveData.CharsInfo();
     if (SaveData._data.tutorialEnd)
     {
         _charInfo = SaveData._data.getCharInfo(itemName);
         if (!SaveData._data.playerHasBook)
         {
             _charInfo.talkNum = 87;
         }
     }
     else
     {
         _charInfo.talkStatus    = SaveData.CharsInfo.TalkStatus.firstTalk;
         _charInfo.talkNum       = 1;
         _charInfo.charTalkFirst = true;
     }
     if (_charInfo.talkStatus == SaveData.CharsInfo.TalkStatus.premissionNotComplete)
     {
         SetSpecialTalk();
     }
     else
     {
         Debug.Log(_charInfo.name + " , " + _charInfo.talkNum + ", " + _charInfo.talkStatus.ToString() + ", " + _charInfo.charTalkFirst);
         if (itemName == "tutorial" || !_charInfo.charTalkFirst || (!SaveData._data.playerHasBook && SaveData._data.tutorialEnd))
         {
             GameManager.game.SetTalk("yellow", _charInfo.talkNum);
         }                                                                                                                                                                                  //player talk first
         else
         {
             GameManager.game.SetTalk(itemName, _charInfo.talkNum); //item talk first
         }
         GameManager.game.Setactive(GameManager.game.TalkUI, true);
     }
 }
示例#3
0
    public void OnEndDrag(PointerEventData eventData)
    {
        if (canDrag)
        {
            GameObject[] targets = GameObject.FindGameObjectsWithTag("target");
            Vector3      pos     = Camera.main.ScreenToWorldPoint(transform.position); pos.z = 0;

            if (targets.Length != 0)
            {
                for (int i = 0; i < targets.Length; i++)
                {
                    if (Vector3.Distance(pos, targets[i].transform.position) < 2.0f)
                    {
                        Debug.Log(targets[i]);
                        //判斷是否為正確目標
                        if (targets[i].name == GetComponent <Image>().sprite.name + "_target")
                        {
                            Debug.Log("delete:" + GetComponent <Image>().sprite.name);
                            if (GetComponent <Image>().sprite.name == "cheese_02")                       //cage has cheese, mouse go to cage
                            {
                                targets[i].GetComponentInChildren <SpriteRenderer>().enabled = true;     //display cheese
                                FindObjectOfType <mouse>()._mishState = mouse.MishState.caught;          //set mouse go to cage
                                FindObjectOfType <mouse>().cagePos.x  = targets[i].transform.position.x; //set mouse cage pos
                                player.DeleteHoldItem(GetComponent <Image>().sprite.name);
                                player.OnItemChanged();
                            }
                            else
                            {
                                SaveData.CharsInfo charInfo = SaveData._data.getCharInfo(targets[i].GetComponentInParent <InteractiveItem>().itemName);

                                if (charInfo.talkStatus == SaveData.CharsInfo.TalkStatus.canDoMission)
                                {
                                    if (GetComponent <Image>().sprite.name == "mouse")
                                    {
                                        targets[i].GetComponentInParent <Animator>().SetTrigger("Eat");
                                        charInfo.talkNum       = 8;
                                        charInfo.charTalkFirst = true;
                                        targets[i].GetComponentInParent <ShowClue>().canShow = true;
                                        //set girl can first talk
                                        SaveData._data.chars[2].talkStatus = SaveData.CharsInfo.TalkStatus.firstTalk;
                                        //set ending
                                        SaveData._data.ending = 2;//破石而出
                                    }
                                    else if (GetComponent <Image>().sprite.name == "diamond")
                                    {
                                        targets[i].GetComponentInParent <Animator>().SetTrigger("Happy");
                                        charInfo.talkNum       = 15;
                                        charInfo.charTalkFirst = true;
                                        //set blue can first talk
                                        targets[i].GetComponentInParent <ShowClue>().canShow = true;
                                        SaveData._data.chars[1].talkStatus = SaveData.CharsInfo.TalkStatus.firstTalk;
                                        SaveData._data.ending = 4;//小湖的死亡
                                    }
                                    else if (GetComponent <Image>().sprite.name == "seed")
                                    {
                                        charInfo.talkNum       = 13;
                                        charInfo.charTalkFirst = true;
                                        targets[i].GetComponentInParent <Animator>().SetTrigger("Eat");
                                        SaveData._data.ending = 5;//被注視的感覺
                                    }
                                    else if (GetComponent <Image>().sprite.name == "flashlight")
                                    {
                                        targets[i].transform.parent.GetChild(1).GetComponent <BoxCollider2D>().enabled = false;
                                        charInfo.talkNum       = 110;
                                        charInfo.charTalkFirst = false;
                                        //set flower small animation
                                        targets[i].GetComponentInParent <Animator>().SetTrigger("Small");
                                        //set player flashlight animation
                                        player.setAnimation(Player.PlayerState.flashlight);
                                    }
                                    else if (GetComponent <Image>().sprite.name == "flower")
                                    {
                                        GameManager.game.Setactive(GameManager.game.FreezerUI, true);
                                        player.Playerstate = Player.PlayerState.interactive;
                                        SoundManager.sound.playOne(SoundManager.sound.uise.click[0]);
                                    }
                                    //save talk data
                                    //delete item
                                    if (GetComponent <Image>().sprite.name != "flower")
                                    {
                                        SaveData._data.setCharInfo(charInfo.name, charInfo);
                                        targets[i].GetComponentInParent <InteractiveItem>().SetTalk();

                                        player.DeleteHoldItem(GetComponent <Image>().sprite.name);
                                        player.OnItemChanged();
                                    }
                                }
                                else if (charInfo.talkStatus == SaveData.CharsInfo.TalkStatus.firstTalk || charInfo.talkStatus == SaveData.CharsInfo.TalkStatus.premissionNotComplete)
                                {
                                    targets[i].GetComponentInParent <InteractiveItem>().SetSpecialTalk();
                                }
                            }
                            break;
                        }
                        else
                        {
                            if (targets[i].name != "cheese_02_target")
                            {
                                SaveData.CharsInfo charInfo = SaveData._data.getCharInfo(targets[i].GetComponentInParent <InteractiveItem>().itemName);
                                if (charInfo.talkStatus == SaveData.CharsInfo.TalkStatus.canDoMission)//解任務 給錯
                                {
                                    if (charInfo.name == "bird")
                                    {
                                        charInfo.talkNum       = 54;
                                        charInfo.charTalkFirst = false;
                                    }
                                    else if (charInfo.name == "girl")
                                    {
                                        charInfo.talkNum       = 21;
                                        charInfo.charTalkFirst = true;
                                    }
                                    else if (charInfo.name == "blue")
                                    {
                                        charInfo.talkNum       = 20;
                                        charInfo.charTalkFirst = true;
                                    }
                                    else if (charInfo.name == "flower")
                                    {
                                        charInfo.talkNum       = 126;
                                        charInfo.charTalkFirst = false;
                                    }
                                    SaveData._data.setCharInfo(charInfo.name, charInfo);
                                    targets[i].GetComponentInParent <InteractiveItem>().SetTalk();
                                }
                                else
                                {
                                    targets[i].GetComponentInParent <InteractiveItem>().SetSpecialTalk();
                                }
                                Debug.Log("uncorrect target");
                            }
                        }
                    }
                }
            }
            myTransform.position = originalPosition;
        }
    }
示例#4
0
文件: Talk.cs 项目: flow996/streemon
    void setTalkBehavior()
    {
        SaveData.CharsInfo _charInfo = new SaveData.CharsInfo();
        for (int i = 0; i < SaveData._data.chars.Length; i++)
        {
            if (nextName.ToString().Contains(SaveData._data.chars[i].name))
            {
                _charInfo = SaveData._data.getCharInfo(SaveData._data.chars[i].name);
                Debug.Log(_charInfo.name);
            }
        }
        if (nextName.ToString().Contains("FirstTalkEnd"))
        {
            _charInfo.talkStatus = SaveData.CharsInfo.TalkStatus.canDoMission;
        }
        else if (nextName.ToString().Contains("End"))
        {
            _charInfo.talkStatus = SaveData.CharsInfo.TalkStatus.missionComplete;
        }
        if (nextName == "birdFirstTalkEnd")
        {
            _charInfo.talkNum       = 6;
            _charInfo.charTalkFirst = true;
            SaveData._data.ending   = 1;
        }
        else if (nextName == "birdrandom")
        {
            _charInfo.talkNum = UnityEngine.Random.Range(0, 2) + 6; //6 or 7
        }
        else if (nextName == "birdEnd")
        {
            _charInfo.talkNum = 14;
        }

        else if (nextName == "girlFirstTalkEnd")
        {
            _charInfo.talkNum       = 30;
            _charInfo.charTalkFirst = false;
            SaveData._data.ending   = 3;//暗影的襲擊
        }
        else if (nextName == "girlTalkEnd" || nextName == "girlEndTalkRandom")
        {
            if (UnityEngine.Random.Range(0, 2) == 0)
            {
                _charInfo.talkNum = 23;
            }
            else
            {
                _charInfo.talkNum = 26;
            }
        }
        else if (nextName == "blueFirstTalkEnd")
        {
            _charInfo.talkNum       = 19;
            _charInfo.charTalkFirst = true;
            SaveData._data.ending   = 4;//小湖的死亡
        }
        else if (nextName == "blueRandom" || nextName == "blueTalkEnd")
        {
            _charInfo.talkNum       = UnityEngine.Random.Range(0, 2) + 11;
            _charInfo.charTalkFirst = true;
            if (nextName == "blueTalkEnd")
            {
                SaveData._data.mainDoorIsLock = true;
                GameManager.game.LockMainDoor();
            }
        }
        else if (nextName == "blueMidTalkEnd")
        {
            _charInfo.talkNum       = 65;
            _charInfo.charTalkFirst = false;
        }
        else if (nextName == "pizzaTalkEnd")
        {
            Pizza _p = GameObject.Find("pizza").GetComponent <Pizza>();
            _p.hasPermission = true;
        }
        //save char info
        SaveData._data.setCharInfo(_charInfo.name, _charInfo);
    }