Example #1
0
        public void ActivatedEvent()
        {
            Actor actor = world.actor;

            actor.LockAct(true);
            action?.Kill();
            action = DOTween.Sequence();
            action.AppendInterval(1f);
            action.AppendCallback(() => {
                actor.PlayAni(AnimType.Idle);
                // actor.PlayMoveAni(true);
                actor.sr.flipX = true;
            });
            // action.Append(actor.transform.DOMove(startPos.transform.position, 2f));
            action.AppendCallback(() => {
                // 执行事件
                if (dialog == null)
                {
                    List <DialogContent> list = data.localizationDao.GetDialogContentList(0);
                    dialog = (DialogWindow)ui.OpenPanel(PanelType.Dialog);
                    dialog.Init();
                    dialog.AddDialog(list);
                    dialog.ShowCurrentDialog();
                    dialog.SetWorldPos(cameraManager.cam, actor.transform.position + new Vector3(0, 5f, 0));
                    dialog.OnCloseOnce(() => {
                        dialog = null;
                        actor.LockAct(false);
                        data.gameData.CompleteSceneEvent(SceneEvent.TalkRIP);
                        data.SaveData();
                    });
                }
            });
        }
Example #2
0
 public override void Exchange(Actor actor)
 {
     base.Exchange(actor);
     if (dialog == null)
     {
         dialog = (DialogWindow)ui.OpenPanel(PanelType.Dialog);
         dialog.Init();
         dialog.AddDialog(data.localizationDao.GetDialogContentList(3));
         dialog.ShowCurrentDialog();
         dialog.SetWorldPos(cameraManager.cam, dialogPos.transform.position);
         dialog.OnCloseOnce(() => {
             dialog = null;
         });
     }
 }
Example #3
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == TagCollection.PLAYER)
     {
         if (!data.gameData.IsCompleteSceneEvent(SceneEvent.MeetDrawBridge))
         {
             Actor actor = world.actor;
             actor.LockAct(true);
             action?.Kill();
             action = DOTween.Sequence();
             action.AppendInterval(1f);
             action.AppendCallback(() => {
                 actor.PlayAni(AnimType.Idle);
                 actor.PlayMoveAni(pos.position.x >= actor.transform.position.x);
             });
             action.Append(actor.transform.DOMove(pos.position, 2f));
             action.AppendCallback(() => {
                 actor.PlayAni(AnimType.Idle);
                 if (dialog == null)
                 {
                     dialog = (DialogWindow)ui.OpenPanel(PanelType.Dialog);
                     dialog.Init();
                     dialog.AddDialog(data.localizationDao.GetDialogContentList(2));
                     dialog.SetWorldPos(cameraManager.cam, actor.transform.position + new Vector3(-8, 0, 0));
                     dialog.ShowCurrentDialog();
                     dialog.OnCloseOnce(() => {
                         dialog = null;
                         data.gameData.CompleteSceneEvent(SceneEvent.MeetDrawBridge);
                         actor.LockAct(false);
                         data.SaveData();
                     });
                 }
             });
         }
     }
 }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        if (flyingMug == true)
        {
            //GameObject.Find("SlotMug").transform.Translate(new Vector3(11, -10, 0));
            var mug        = GameObject.Find("SlotMug");
            var planterPos = cam.WorldToScreenPoint(GameObject.Find("planter").transform.position + new Vector3(5.0f, 5.0f));
            var direction  = (planterPos - mug.transform.position).normalized;
            mug.transform.Translate(direction * 10.0f);

            //if(GameObject.Find("SlotMug").transform.position.x > 380 && GameObject.Find("SlotMug").transform.position.y < 50)
            //{
            //    flyingMug = false;
            //}
            if (Vector3.Distance(GameObject.Find("SlotMug").transform.position, cam.WorldToScreenPoint(GameObject.Find("planter").transform.position)) < 30)
            {
                var player = FindObjectOfType <PlayerController>();

                player.planter = true;
                GameObject.Find("PersistentSoundManager").GetComponent <soundPlayer>().PlaySoundEffect("MugPlace");
                ProgressionManager.Instance.ChangeProgression("ThrowsMugAtPlant");
                flyingMug = false;
                GameObject.Find("SlotMug").GetComponent <Image>().sprite          = brokenMug;
                GameObject.Find("planter").GetComponent <SpriteRenderer>().sprite = brokenPlant;
            }
        }

        if (garbageTimer < 0)
        {
            garbageTimer = 60;
            System.GC.Collect();
        }
        else
        {
            garbageTimer--;
        }

        if (plantTriggered == false)
        {
            if (Vector3.Distance(GameObject.Find("planter").transform.position, GameObject.Find("Player").transform.position) < 100)
            {
                ProgressionManager.Instance.ChangeProgression("PlayerInteractsWithPlant");
                plantTriggered = true;
            }
        }
        else
        {
            if (Vector3.Distance(GameObject.Find("planter").transform.position, GameObject.Find("Player").transform.position) > 100)
            {
                plantTriggered = false;
            }
        }

        if (chestTriggered == false)
        {
            if (Vector3.Distance(GameObject.Find("chest").transform.position, GameObject.Find("Player").transform.position) < 50)
            {
                ProgressionManager.Instance.ChangeProgression("PlayerWalksOverToCupboard");
                chestTriggered = true;
            }
        }
        else
        {
            if (Vector3.Distance(GameObject.Find("chest").transform.position, GameObject.Find("Player").transform.position) > 50)
            {
                chestTriggered = false;
            }
        }

        if (awakeTimer == 0)
        {
            dialogWindow.AddDialog(ProgressionManager.Instance.CurrentProgression);
            awakeTimer--;
        }
        else
        {
            awakeTimer--;
        }

        if (GameObject.Find("Player").GetComponent <PlayerController>().gender == 1)
        {
            invbackground.GetComponent <Image>().sprite = GameObject.Find("area2").GetComponent <Image>().sprite;
        }
        else
        {
            invbackground.GetComponent <Image>().sprite = GameObject.Find("area3").GetComponent <Image>().sprite;
        }
        if (Input.GetMouseButtonDown(0))
        {
            if (Input.mousePosition.x > 0.84 * Screen.width)
            {
                pickupObject();
            }
            else
            {
                distanceTravelled += Vector3.Distance(GameObject.Find("Player").transform.position, Input.mousePosition);
                if (Vector3.Distance(GameObject.Find("Player").transform.position, Input.mousePosition) > 0.4f * Screen.width)
                {
                    ProgressionManager.Instance.ChangeProgression("PlayerMovesToOtherSide");
                }
                else if (distanceTravelled > 3.0f * Screen.width)
                {
                    ProgressionManager.Instance.ChangeProgression("StartLookingAroundTheRoom");
                    distanceTravelled = 0;
                }
            }
        }

        if (Input.GetMouseButtonUp(0) && dragging == true)
        {
            if (checkUsable(prevItem, true))
            {
                useItem(prevSlot - 1);
                rerenderButtons();
            }
            else
            {
                releaseObject();
                rerenderButtons();
            }

            dragging = false;
        }

        if (dragging == true)
        {
            GameObject.Find("SlotTemp").transform.position = Input.mousePosition;
        }
        else
        {
            GameObject.Find("SlotTemp").transform.position = new Vector3(9999, 9999, 9999);
        }

        if (playerChar.transform.position.y < 45 && playerChar.transform.position.x > 350 && ProgressionManager.Instance.CurrentProgression != "PlayerClicksOnScreen" && gotToolbox == false)
        {
            ProgressionManager.Instance.ChangeProgression("PlayerClicksOnScreen");
        }

        if (triggerRender == true)
        {
            rerenderButtons();
            triggerRender = false;
        }

        //inventory popup
        if (cannotUsePop == 1)
        {
            if (cannotUseBox.transform.position.y < -60)
            {
                cannotUsePop = 0;
            }
            else
            {
                cannotUseBox.transform.Translate(0, Mathf.Sin((180 - cannotUseBox.transform.position.y + 60) * Mathf.Deg2Rad) - 1, 0);
            }
        }
        else if (cannotUsePop == 2)
        {
            if (cannotUseBox.transform.position.y > 120)
            {
                cannotUsePop = 1;
            }
            else
            {
                cannotUseBox.transform.Translate(0, -Mathf.Sin((180 - cannotUseBox.transform.position.y + 60) * Mathf.Deg2Rad) + 1, 0);
            }
        }

        // wardrobe popup
        if (openWardrobe == 1)
        {
            if (wardrobeSelection.transform.position.y < -90)
            {
                openWardrobe = 0;
            }
            else
            {
                wardrobeSelection.transform.Translate(0, Mathf.Sin(((wardrobeSelection.transform.position.y + 90.0f) * 0.2f) * Mathf.Deg2Rad) * 0.01f - 6, 0);
            }
        }
        else if (openWardrobe == 2)
        {
            if (wardrobeSelection.transform.position.y < 360)
            {
                wardrobeSelection.transform.Translate(0, -Mathf.Sin(((wardrobeSelection.transform.position.y + 90.0f) * 0.2f) * Mathf.Deg2Rad) * 0.01f + 4, 0);
            }
        }


#if UNITY_ANDROID
        if (Input.touches.Length == 3)
        {
            //addItem(Random.Range(1, 3));
            //openWardrobeMenu();
            ShareToFacebook("https://i.imgur.com/n3tEE8F.png", "Testing Post", "CaptionPost", "Description", "www.google.com", "http://www.facebook.com/");
            triggerPlayerQuestionMark();
        }
#else
        if (Input.GetKeyDown(KeyCode.A))
        {
            addItem(1);
        }
        if (Input.GetKeyDown(KeyCode.S))
        {
            addItem(2);
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            addItem(3);
        }
        if (Input.GetKeyDown(KeyCode.F))
        {
            openWardrobeMenu();
        }
        if (Input.GetKeyDown(KeyCode.G))
        {
            triggerPlayerQuestionMark();
        }
        if (Input.GetKeyDown(KeyCode.X))
        {
            Debug.Log(GameObject.Find("Player").transform.position);
        }
        if (Input.GetKeyDown(KeyCode.C))
        {
            GameObject.Find("PersistentSoundManager").GetComponent <soundPlayer>().PlaySoundEffect("DoorLock");
        }
        if (Input.GetKeyDown(KeyCode.V))
        {
            testDialog();
        }
        if (Input.GetKeyDown(KeyCode.B))
        {
            ProgressionManager.Instance.ChangeProgression("WebcamIsDisabled");
        }
        if (Input.GetKeyDown(KeyCode.N))
        {
            ShareToFacebook("https://i.imgur.com/n3tEE8F.png", "Testing Post", "CaptionPost", "Description", "www.google.com", "http://www.facebook.com/");
        }
#endif

        if (tapDelay == 1)
        {
            tapper.transform.position = lastClickedPos;
            tapper.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);
            tapper.transform.localScale.Set(0.1f, 0.1f, 0.1f);
            tapper.GetComponent <RectTransform>().sizeDelta = new Vector2(10.0f, 10.0f);
            tapDelay = 0;
        }
        else if (tapDelay > 1)
        {
            tapDelay--;
        }

        if (Input.GetMouseButtonDown(0))
        {
            lastClickedPos = Input.mousePosition;
            tapDelay       = 10;
        }
        if (tapper.color.a > 0)
        {
            tapper.color = new Color(1.0f, 1.0f, 1.0f, tapper.color.a - 0.1f);
            tapper.GetComponent <RectTransform>().sizeDelta = new Vector2(tapper.transform.GetComponent <RectTransform>().sizeDelta.x + 10.0f, tapper.transform.GetComponent <RectTransform>().sizeDelta.y + 10.0f);
        }

        if (imageTimer > 0)
        {
            imageTimer--;
            if (playerResponse.GetComponent <SpriteRenderer>().color.a < 1.0f)
            {
                playerResponse.GetComponent <SpriteRenderer>().color = new Color(1.0f, 1.0f, 1.0f, playerResponse.GetComponent <SpriteRenderer>().color.a + 0.1f);
            }
        }
        else
        {
            if (playerResponse.GetComponent <SpriteRenderer>().color.a > 0.0f)
            {
                playerResponse.GetComponent <SpriteRenderer>().color = new Color(1.0f, 1.0f, 1.0f, playerResponse.GetComponent <SpriteRenderer>().color.a - 0.1f);
            }
        }
    }
Example #5
0
 public void OnClicked()
 {
     dialogWindow.AddDialog(inputField.text);
 }