Exemplo n.º 1
0
    /// <summary>
    /// 探索対象を獲得する
    /// </summary>
    /// <param name="eventData"></param>
    /// <param name="treasureBox"></param>
    /// <returns></returns>
    public IEnumerator DisplaySearchDialog(EventData eventData, TreasureBox treasureBox)
    {
        // 会話ウインドウを表示
        canvasGroup.DOFade(1.0f, 0.5f);

        // タイトルに探索物の名称を表示
        txtTitleName.text = eventData.title;

        // アイテム獲得
        yield return(StartCoroutine(GetEventItems(eventData.eventDataDetailsList[0])));

        // 閉じる
        treasureBox.CloseTreasureBox();

        // 獲得した宝箱の番号を GameData に追加
        GameData.instance.AddSearchEventNum(treasureBox.treasureEventNo);

        // 獲得した宝箱の番号をセーブ
        GameData.instance.SaveSearchEventNum(treasureBox.treasureEventNo);

        // 所持しているアイテムのセーブ
        GameData.instance.SaveItemInventryDatas();

        // TODO お金や経験値のセーブ
    }
    /// <summary>
    ///
    /// </summary>
    /// <param name="collision"></param>
    private void OnCollisionEnter2D(Collision2D collision)
    {
        // Check if hit any game element
        GameElement element = collision.collider.GetComponent <GameElement>();

        if (element != null)
        {
            element.HitByPlayerShot();
        }
        else
        {
            // Check if hit a grave
            Grave grv = collision.collider.GetComponent <Grave>();
            if (grv != null)
            {
                grv.HitByPlayerShot();
            }
        }

        // Check if hit a treasure box
        TreasureBox treasure = collision.collider.GetComponent <TreasureBox>();

        if (treasure != null)
        {
            treasure.Destroy();
        }

        // Always destroy the shot when hits something
        this.Destroy();
    }
Exemplo n.º 3
0
    private void Awake()
    {
        nexts        = new GameObject[DirectionMax];
        nexts[North] = UIUtil.FindChild <Transform>(transform, "NorthDoor").gameObject;
        nexts[East]  = UIUtil.FindChild <Transform>(transform, "EastDoor").gameObject;
        nexts[West]  = UIUtil.FindChild <Transform>(transform, "WestDoor").gameObject;

        stair = UIUtil.FindChild <RoomStair>(transform, "Stair");
        stair.gameObject.SetActive(true);

        treasure_box = UIUtil.FindChild <TreasureBox>(transform, "Box");
        treasure_box.gameObject.SetActive(true);
        npc = UIUtil.FindChild <SpriteRenderer>(transform, "Npc");
        npc.gameObject.SetActive(true);
    }
        private void AddItem(int i)
        {
            MissionInfo info = missionConfig.GetMissionInfoByMissionId(dataManager.missionId);

            if (info != null && i < info.listTreasureBox.Count)
            {
                TreasureBox treasureBox = treasureBoxConfig.GetTreasureBoxById(info.listTreasureBox[i].BoxId);
                foreach (var treasure in treasureBox.items)
                {
                    Item item = itemConifg.GetItemById(treasure.itemId);
                    if (item != null && item.Type == 4)
                    {
                        itemsDataManager.AddItem(treasure.itemId);
                    }
                }
            }
        }
    public static void Main(string[] args)
    {
        TreasureBox t = new TreasureBox();
        Parachute   p = new Parachute();

        Console.WriteLine("Enter the letter found in the paper");
        char ch = Console.ReadLine()[0];

        if (ch == 'T')
        {
            Console.WriteLine(t.OpenSesame());
        }
        else if (ch == 'P')
        {
            Console.WriteLine(p.OpenSesame());
        }
    }
Exemplo n.º 6
0
        private void OpenNimItemBox(UIState state)
        {
            this.uiNimBox.SetStatus(true);
            this.uiNimBox.NimImage.gameObject.SetActive(false);
            MissionInfo info = this.MissionConfig.GetMissionInfoByMissionId(missionId);

            if (info != null && this.treasureBoxIndex < info.listTreasureBox.Count)
            {
                TreasureBox treasureBox = this.TreasureBoxConfig.GetTreasureBoxById(info.listTreasureBox[this.treasureBoxIndex].BoxId);
                foreach (var treasure in treasureBox.items)
                {
                    GameObject resource = this.PrefabRoot.GetGameObject("Scenes", this.ItemConifg.GetImage(treasure.itemId));
                    if (resource && resource.GetComponent <SpriteRenderer>() != null)
                    {
                        uiNimBox.NimImage.sprite = resource.GetComponent <SpriteRenderer>().sprite;
                        Destroy(resource);
                    }
                }
            }

            this.uiNimBox.TreasureOpen.AnimationState.ClearTracks();
            this.uiNimBox.TreasureOpen.AnimationState.SetAnimation(0, "unboxing", false).Complete += delegate(Spine.TrackEntry track)
            {
                Debug.LogFormat("<><TreasureBoxOpen.OpenNimItemBox>Sound: {0}, HasModulePageOpened: {1}, InGuideView: {2}",
                                "nim_chest_open_" + LocalPetInfoAgent.getCurrentPet(), TopViewHelper.Instance.HasModulePageOpened(),
                                TopViewHelper.Instance.IsInGuideView());
                if (!TopViewHelper.Instance.HasModulePageOpened() || TopViewHelper.Instance.IsInGuideView())
                {//没有打开任何功能模块或正在引导才能播放此声音
                    Debug.LogFormat("<><TreasureBoxOpen.OpenNimItemBox>Sound: {0} ==== Playing", "nim_chest_open_" + LocalPetInfoAgent.getCurrentPet());
                    SoundPlayer.GetInstance().PlaySoundType("nim_chest_open_" + LocalPetInfoAgent.getCurrentPet());
                }
            };
            this.uiNimBox.TreasureOpen.AnimationState.AddAnimation(0, "Biological appearance", true, 0).Complete += delegate(Spine.TrackEntry track)
            {
                this.uiNimBox.NimImage.gameObject.SetActive(true);
                this.UIStateCompleteSignal.Dispatch(GetStateEnum());
                if (track.Loop)
                {
                    this.okButton.SetActive(true);
                }
            };
        }
Exemplo n.º 7
0
        private void OpenPropsItemBox(UIState state)
        {
            this.uiPropsBox.SetStatus(true);
            this.uiPropsBox.SetPosition(320.0f, 0.0f);
            this.uiPropsBox.SetPosition(0.0f, 0.5f);
            this.uiPropsBox.uiPropsItems.ForEach(t => t.SetStatus(false));
            MissionInfo missionInfo = this.MissionConfig.GetMissionInfoByMissionId(missionId);

            if (missionInfo != null && this.treasureBoxIndex < missionInfo.listTreasureBox.Count)
            {
                TreasureBox treasureBox = this.TreasureBoxConfig.GetTreasureBoxById(missionInfo.listTreasureBox[this.treasureBoxIndex].BoxId);
                for (int i = 0; i < treasureBox.items.Count; i++)
                {
                    GameObject resource = this.PrefabRoot.GetGameObject("Scenes", this.ItemConifg.GetImage(treasureBox.items[i].itemId));
                    if (resource && resource.GetComponent <SpriteRenderer>() != null)
                    {
                        this.uiPropsBox.uiPropsItems[i].SetStatus(true);
                        this.uiPropsBox.uiPropsItems[i].SetContent(resource.GetComponent <SpriteRenderer>().sprite, treasureBox.items[i].count);
                        this.FundDataManager.AddProperty(treasureBox.items[i].itemId, treasureBox.items[i].count);
                        Destroy(resource);
                    }
                }
            }

            Debug.LogFormat("<><TreasureBoxOpen.OpenPropsItemBox>Sound: {0}, HasModulePageOpened: {1}, InGuideView: {2}",
                            "nim_chest_open_" + LocalPetInfoAgent.getCurrentPet(), TopViewHelper.Instance.HasModulePageOpened(),
                            TopViewHelper.Instance.IsInGuideView());
            if (!TopViewHelper.Instance.HasModulePageOpened() || TopViewHelper.Instance.IsInGuideView())
            {//没有打开任何功能模块或正在引导才能播放此声音
                Debug.LogFormat("<><TreasureBoxOpen.OpenPropsItemBox>Sound: {0} ==== Playing", "nim_chest_open_" + LocalPetInfoAgent.getCurrentPet());
                SoundPlayer.GetInstance().PlaySoundType("nim_chest_open_" + LocalPetInfoAgent.getCurrentPet());
            }

            UIStateCompleteSignal.Dispatch(GetStateEnum());
            okButton.SetActive(true);
        }
Exemplo n.º 8
0
    public void characterMove()
    {
        if (!Input.GetKey(KeyCode.LeftAlt))           //if we are not using the ALT key(camera control)...
        {
            if (Input.GetMouseButton(0))
            {
                rightmouse = 0;
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);                 //从摄像机发出到点击坐标的射线
                if (Physics.Raycast(ray, out hitInfo))
                {
                    Debug.DrawLine(ray.origin, hitInfo.point);                     //划出射线,只有在scene视图中才能看到
                    gameObj = hitInfo.collider.gameObject;
                    Debug.Log("left click object name is " + gameObj.name);
                    movementTargetPosition = hitInfo.point;
                    minDist = 1f;
                }
            }
            if (rightmouse == 0)
            {
                if (gameObj.tag == "Player")
                {
                    movementTargetPosition = gameObj.transform.position;
                }
                else if (gameObj.tag == "MonsterA")
                {
                    //				Debug.Log ("MonsterA");
                    if (WeaponState != 2 && heroList [0] == false)
                    {
                        minDist = 3f;
                        movementTargetPosition = gameObj.transform.position;
                    }
                }
                else if (gameObj.tag == "MonsterB")
                {
                    Debug.Log("MonsterB");
                    if (WeaponState != 4 && heroList [1] == false)
                    {
                        minDist = 3f;
                        movementTargetPosition = gameObj.transform.position;
                    }
                }
                else if (gameObj.tag == "MonsterC")
                {
                    Debug.Log("MonsterC");
                    if (WeaponState != 7 && heroList [2] == false)
                    {
                        minDist = 3f;
                        movementTargetPosition = gameObj.transform.position;
                    }
                }
                else if (gameObj.tag == "Zombie")
                {
                    Debug.Log("Zombie");
                    minDist = 3f;
                    movementTargetPosition = gameObj.transform.position;
                }
                else if (gameObj.tag == "Boss")
                {
                    Debug.Log("Boss");
                    minDist = 3f;
                    movementTargetPosition = gameObj.transform.position;
                }
            }



            if (Input.GetMouseButton(1))
            {
                rightmouse = 1;
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);                 //从摄像机发出到点击坐标的射线
                if (Physics.Raycast(ray, out hitInfo))
                {
                    Debug.DrawLine(ray.origin, hitInfo.point);                     //划出射线,只有在scene视图中才能看到
                    gameObj = hitInfo.collider.gameObject;
                    Debug.Log("right click object name is " + gameObj.name);
                    isFight  = false;
                    isObject = false;
                }
            }

            if (rightmouse == 1 && gameObj != null)
            {
                if (gameObj.tag == "MonsterA")
                {
                    Debug.Log("Attack MonsterA");
                    if (WeaponState != 2 && heroList [0] == false)
                    {
                        isFight  = true;
                        isObject = false;
                        minDist  = 3.5f;
                        movementTargetPosition = gameObj.transform.position;
                    }
                }
                else if (gameObj.tag == "MonsterB")
                {
                    Debug.Log("MonsterB");
                    if (WeaponState != 4 && heroList [1] == false)
                    {
                        isFight  = true;
                        isObject = false;
                        minDist  = 3.5f;
                        movementTargetPosition = gameObj.transform.position;
                    }
                }
                else if (gameObj.tag == "MonsterC")
                {
                    Debug.Log("MonsterC");
                    if (WeaponState != 7 && heroList [2] == false)
                    {
                        isFight  = true;
                        isObject = false;
                        minDist  = 3.5f;
                        movementTargetPosition = gameObj.transform.position;
                    }
                }
                else if (gameObj.tag == "Zombie")
                {
                    Debug.Log("Zombie");
                    isFight  = true;
                    isObject = false;
                    minDist  = 3.5f;
                    movementTargetPosition = gameObj.transform.position;
                }
                else if (gameObj.tag == "Boss")
                {
                    Debug.Log("Boss");
                    isFight  = true;
                    isObject = false;
                    minDist  = 3.5f;
                    movementTargetPosition = gameObj.transform.position;
                }
                else if (gameObj.tag == "Drug")
                {
                    Debug.Log("Drug");
                    isFight  = false;
                    isObject = true;
                    minDist  = 2f;
                    movementTargetPosition = gameObj.transform.position;
                    treasureBox            = gameObj.GetComponent <TreasureBox> ();
                }
                else if (gameObj.tag == "TotemA")
                {
                    Debug.Log("TomtemA");
                    isFight  = false;
                    isObject = true;
                    minDist  = 2f;
                    movementTargetPosition = gameObj.transform.position;
                }
                else if (gameObj.tag == "TotemB")
                {
                    Debug.Log("TotemB");
                    isFight  = false;
                    isObject = true;
                    minDist  = 2f;
                    movementTargetPosition = gameObj.transform.position;
                }
                else if (gameObj.tag == "TotemC")
                {
                    Debug.Log("TotemC");
                    isFight  = false;
                    isObject = true;
                    minDist  = 2f;
                    movementTargetPosition = gameObj.transform.position;
                }
                else if (gameObj.tag == "TreasureC")
                {
                    Debug.Log("TreasureC");
                    isFight  = false;
                    isObject = true;
                    minDist  = 2f;
                    movementTargetPosition = gameObj.transform.position;
                }
            }
        }

        //AttackCode has to go here for targeting reasons
        //		Vector3 deltaTarget = movementTargetPosition - transform.position;
        if (isFight == false && rightmouse == 1 && isObject == false)          //stop attack
        {
            movementTargetPosition = transform.position;
        }
        deltaTarget = movementTargetPosition - transform.position;

        lookAtPos   = transform.position + deltaTarget.normalized * 2.0f;
        lookAtPos.y = transform.position.y;


        Quaternion tempRot = transform.rotation;                //save current rotation

        transform.LookAt(lookAtPos);
        Quaternion hitRot = transform.rotation;                 // store the new rotation

        // now we slerp orientation
        transform.rotation = Quaternion.Slerp(tempRot, hitRot, Time.deltaTime * rotateSpeed);

        if (Vector3.Distance(movementTargetPosition, transform.position) > minDist)
        {
            animator.SetBool("Idling", false);
        }
        else
        {
            animator.SetBool("Idling", true);

            if (minDist == 3.5f && timer > minAttackTime && isFight == true && gameObj != null)
            {
                timer = 0.0f;
                attack();
            }
            else if (minDist == 2f && isObject == true && gameObj != null)
            {
                if (gameObj.tag == "Drug")
                {
                    if (treasureBox.count_treasure() == 1)
                    {
                        treasureBox.box_behaviour();                            // guarantee this function is excuted only one time.
                    }
                    if (!treasureBox.isEmpty())
                    {
                        treasureBox.distribution();
                        System.Random rd      = new System.Random();
                        int           randKey = rd.Next(1, 100);
                        if (0 < randKey && randKey <= 80)
                        {
                            drug_num [0]++;
                        }
                        else if (80 < randKey && randKey <= 90)
                        {
                            drug_num [1]++;
                        }
                        else
                        {
                            drug_num [2]++;
                        }
                    }
                }
                else if (gameObj.tag == "TotemA")
                {
                    if (getTaskA == false && WeaponState == 2)
                    {
                        getTaskA = true;
                    }
                    else if (getTaskA == true && finishTaskA == false && WeaponState == 2)
                    {
                        if (num_killZobiem >= 5)
                        {
                            finishTaskA  = true;
                            heroList [0] = true;
                        }
                    }
                    else if (finishTaskA == true && guarderA == false)
                    {
                        createGuarderA();
                    }
                }
                else if (gameObj.tag == "TotemB")
                {
                    if (getTaskB == false && WeaponState == 4)
                    {
                        getTaskB = true;
                    }
                    else if (getTaskB == true && finishTaskB == false && WeaponState == 4)
                    {
                        if (num_killMonsterC >= 3)
                        {
                            finishTaskB  = true;
                            heroList [1] = true;
                        }
                    }
                    else if (finishTaskB == true && guarderB == false)
                    {
                        createGuarderB();
                    }
                }
                else if (gameObj.tag == "TotemC")
                {
                    if (getTaskC == false && WeaponState == 7)
                    {
                        getTaskC = true;
                    }
                    else if (getTaskC == true && finishTaskC == false && WeaponState == 7)
                    {
                        if (getTreasureC == true)
                        {
                            finishTaskC  = true;
                            heroList [2] = true;
                        }
                    }
                    else if (finishTaskC == true && guarderC == false)
                    {
                        createGuarderC();
                    }
                }
                else if (gameObj.tag == "TreasureC")
                {
                    getTreasureC = true;
                }

                timer += Time.deltaTime;
            }
            else
            {
                timer += Time.deltaTime;
            }
        }
    }
Exemplo n.º 9
0
 public void Init(TreasureBox treasureBox, BattleMapManager battleMapManager, Main_Map map)
 {
     this.battleMapManager = battleMapManager;
     this.map         = map;
     this.treasureBox = treasureBox;
 }
Exemplo n.º 10
0
 public void OpenSearchWindow(EventData eventData, TreasureBox treasureBox)
 {
     StartCoroutine(dialogController.DisplaySearchDialog(eventData, treasureBox));
 }