Пример #1
0
 public void KeyDown(int key)
 {
     if (keyContactData == null)
     {
         return;
     }
     if (iGameState.GameRunType != EnumGameRunType.Safe && iGameState.GameRunType != EnumGameRunType.Unsafa)
     {
         return;
     }
     if (iPlayerState.KeyContactDataZone != EnumKeyContactDataZone.Normal)//如果此时不是释放技能的键位,则不需要下面的判断
     {
         return;
     }
     KeyContactStruct[] keyContactStructs = keyContactData.GetKeyContactStruct(key, temp => temp.keyContactType == EnumKeyContactType.Skill);
     if (keyContactStructs.Length > 0)
     {
         foreach (KeyContactStruct keyContactStruct in keyContactStructs)//便利所有按键对象
         {
             int skillID = keyContactStruct.id;
             //组合技能放入技能组合盘
             if (skillID > (int)EnumSkillType.MagicCombinedStart)
             {
                 EnumSkillType[]   enumSkillTypes = SkillCombineStaticTools.GetCombineSkills(skillID);
                 SkillBaseStruct[] combineSkills  = skillStructData.SearchSkillDatas(temp => enumSkillTypes.Contains(temp.skillType));
                 iSkillState.CombineSkills = combineSkills;
             }
             else if (skillID > (int)EnumSkillType.MagicCombinedLevel1Start && skillID < (int)EnumSkillType.MagicCombinedLevel4End)
             {
                 SkillBaseStruct[] singleCombineSkills = skillStructData.SearchSkillDatas(temp => (EnumSkillType)skillID == temp.skillType);
                 iSkillState.CombineSkills = singleCombineSkills;
             }
             //如果按下魔法释放键,则释放组合盘中的魔法
             else if (skillID == (int)EnumSkillType.MagicRelease)
             {
                 iSkillState.StartCombineSkillRelease();
             }
             else//非组合技能直接释放
             {
                 iSkillState.ReleaseNormalSkill(skillStructData.SearchSkillDatas(temp => (int)temp.skillType == skillID).FirstOrDefault());
             }
         }
     }
     else if (keyContactData.GetKeyContactStruct(key, temp => temp.keyContactType == EnumKeyContactType.None).Count() == 1)//如果输入了空的按键则
     {
         iSkillState.CombineSkills = null;
     }
 }
    public void KeyDown(int key)
    {
        if (keyContactData == null || iPlayerState == null || iGameState == null || playerState == null)
        {
            return;
        }
        if (iGameState.GameRunType != EnumGameRunType.Unsafa && iGameState.GameRunType != EnumGameRunType.Safe)
        {
            return;
        }
        KeyContactStruct[] keyContactStructs = keyContactData.GetKeyContactStruct(key, temp => temp.keyContactType == EnumKeyContactType.Prap, iPlayerState.KeyContactDataZone);
        if (keyContactStructs.Length == 0)
        {
            return;
        }
        KeyContactStruct keyContactStruct = keyContactStructs[0];
        PlayGoods        playGoods        = playerState.PlayerAllGoods.Where(temp => temp.ID == keyContactStruct.id).FirstOrDefault();

        if (playGoods == null)
        {
            return;
        }
        //暂时这么写
        if (playGoods.GoodsInfo.EnumGoodsType == EnumGoodsType.HFYJ)
        {
            iPlayerState.EatMedicine(playGoods.ID);
        }
    }
Пример #3
0
    // Use this for initialization
    void Start()
    {
        List <Archive> allArchives = DataCenter.Instance.GetAllArchive();

        //不存在id为1的存档就来一份吧~
        if (allArchives.All(a => a.ID != 1))
        {
            DataCenter.Instance.Save(1, "firstTest", "testIntro");
        }

        //加载存档1
        DataCenter.Instance.LoadArchive(1);

        //测试任务
        MetaTasksData metaTaskDataSystem = DataCenter.Instance.GetMetaData <MetaTasksData>();


        RuntimeTasksData runtimeTaskData = DataCenter.Instance.GetEntity <RuntimeTasksData>();

        List <RunTimeTaskInfo> allCanDotask = runtimeTaskData.GetAllToDoList();

        RunTimeTaskInfo firstTask = allCanDotask[0];

        //根据runtimetask的id去metaTask里拿Task的所有信息
        MetaTaskInfo firstTaskMetaInfo = metaTaskDataSystem[firstTask.ID];

        Debug.Log(firstTaskMetaInfo.MetaTaskNode.TaskLocation);
        Debug.Log(firstTaskMetaInfo.MetaTaskNode.TaskTitile);
        Debug.Log(firstTaskMetaInfo.MetaTaskNode.TaskType);

        //******任务具体逻辑************

        //任务完成
        firstTask.IsOver = true;
        //获取新任务继续
        var newTaskList = runtimeTaskData.GetAllToDoList();

        //获取按键数据
        KeyContactData keyContactData = DataCenter.Instance.GetEntity <KeyContactData>();

        keyContactData.SetKeyContactStruct(1, new KeyContactStruct()
        {
            id = 1, key = 2, keyContactType = EnumKeyContactType.Action
        });
        var keyDataStructs = keyContactData.GetKeyContactStruct(1);

        //获取 PlayerState
        PlayerState playerState = DataCenter.Instance.GetEntity <PlayerState>();

        playerState.Agility = 1;
        playerState.Level   = 20;



        //写入数据
        DataCenter.Instance.Save(2, "test2", "test2");
        Debug.Log("存档成功");
    }
    public void KeyDown(int key)
    {
        if (keyContactData == null || iPlayerState == null || iInteractiveState == null)
        {
            return;
        }
        if (iGameState.GameRunType != EnumGameRunType.Unsafa &&
            iGameState.GameRunType != EnumGameRunType.Safe)
        {
            return;
        }
        KeyContactStruct[] keyContactStructs = keyContactData.GetKeyContactStruct(key, temp => temp.keyContactType == EnumKeyContactType.Action, iPlayerState.KeyContactDataZone);
        if (keyContactStructs.Length == 0)
        {
            return;
        }
        switch (iPlayerState.KeyContactDataZone)
        {
        case EnumKeyContactDataZone.Normal:
            break;

        case EnumKeyContactDataZone.Collect:
            if (keyContactStructs[0].id == 1)
            {
                if (iPlayerState.TouchTargetStruct.ID > -1)
                {
                    iInteractiveState.ClickInteractiveStuffID = iPlayerState.TouchTargetStruct.ID;
                }
            }
            break;

        case EnumKeyContactDataZone.Dialogue:
            if (keyContactStructs[0].id == 2)
            {
                if (iPlayerState.TouchTargetStruct.ID > -1)
                {
                    iInteractiveState.ClickInteractiveNPCID = iPlayerState.TouchTargetStruct.ID;
                }
            }
            break;

        case EnumKeyContactDataZone.Action:
            if (keyContactStructs[0].id == 3)
            {
                if (iPlayerState.TouchTargetStruct.ID > -1)
                {
                    iInteractiveState.ClickActionInteractiveID = iPlayerState.TouchTargetStruct.ID;
                }
            }
            break;
        }
    }
Пример #5
0
 /// <summary>
 /// 当显示时初始化按键数据
 /// </summary>
 private void OnEnable()
 {
     playerState     = DataCenter.Instance.GetEntity <PlayerState>();
     keyContactData  = DataCenter.Instance.GetEntity <KeyContactData>();
     skillStructData = DataCenter.Instance.GetMetaData <SkillStructData>();
     selectTargetPanel.gameObject.SetActive(false);
     UIManager.Instance.KeyUpHandle += Instance_KeyUpHandle;
     enumKeySettingType              = EnumKeySettingType.Lattice;
     if (keySettingFocusPath)
     {
         nowKeySettingLattice = keySettingFocusPath.GetFirstFocus() as UIFocusKeySettingLattice;
         if (nowKeySettingLattice)
         {
             nowKeySettingLattice.SetForcus();
         }
         //初始化显示
         UIFocus[] uiKeySettingLatticeArray = keySettingFocusPath.NewUIFocusArray;// keySettingFocusPath.UIFocuesArray;
         foreach (UIFocus item in uiKeySettingLatticeArray)
         {
             if (!item)
             {
                 continue;
             }
             UIFocusKeySettingLattice uiKeySettingLattice = item as UIFocusKeySettingLattice;
             int inputKey = uiKeySettingLattice.GetKeySettingInput();//输入的按键值
             if (uiKeySettingLattice)
             {
                 KeyContactStruct[] keyContactStructs = keyContactData.GetKeyContactStruct(inputKey);
                 if (keyContactStructs.Length > 0)
                 {
                     uiKeySettingLattice.keyLatticeType = keyContactStructs[0].keyContactType;
                     uiKeySettingLattice.id             = keyContactStructs[0].id;
                 }
                 else
                 {
                     uiKeySettingLattice.keyLatticeType = EnumKeyContactType.None;
                     uiKeySettingLattice.id             = 0;
                 }
                 //初始化显示
                 uiKeySettingLattice.InitShow();
             }
         }
     }
 }
    private void Show()
    {
        if (skillStructData == null || playerState == null || keyImage == null)
        {
            return;
        }
        KeyContactStruct keyContactStruct = default(KeyContactStruct);

        //这里存在优化空间
        if (r1Press)
        {
            keyContactStruct = keyContactData.GetKeyContactStruct(InputType | (int)EnumInputType.RB, null, iPlayerState.KeyContactDataZone).FirstOrDefault();
        }
        else if (r2Press)
        {
            keyContactStruct = keyContactData.GetKeyContactStruct(InputType | (int)EnumInputType.RT, null, iPlayerState.KeyContactDataZone).FirstOrDefault();
        }
        else if (l1Press)
        {
            keyContactStruct = keyContactData.GetKeyContactStruct(InputType | (int)EnumInputType.LB, null, iPlayerState.KeyContactDataZone).FirstOrDefault();
        }
        else if (l2Press)
        {
            keyContactStruct = keyContactData.GetKeyContactStruct(InputType | (int)EnumInputType.LT, null, iPlayerState.KeyContactDataZone).FirstOrDefault();
        }
        else
        {
            keyContactStruct = keyContactData.GetKeyContactStruct(InputType, null, iPlayerState.KeyContactDataZone).FirstOrDefault();
        }

        switch (keyContactStruct.keyContactType)
        {
        case EnumKeyContactType.None:
            keyImage.sprite       = null;
            innerImage.fillAmount = 0;
            break;

        case EnumKeyContactType.Skill:
            int skillKey = keyContactStruct.id;
            if (skillKey > (int)EnumSkillType.MagicCombinedStart)
            {
                keyImage.sprite = SkillCombineStaticTools.GetCombineSkillSprite(skillStructData, skillKey);
            }
            else
            {
                keyImage.sprite = skillStructData.SearchSkillDatas(temp => (int)temp.skillType == skillKey).Select(temp => temp.skillSprite).FirstOrDefault();
            }
            //这里还需要判断是不是没有冷却的技能,比如魔法释放 普通攻击等
            if (skillKey != (int)EnumSkillType.MagicRelease && skillKey != (int)EnumSkillType.PhysicAttack)
            {
                innerImage.fillAmount = Mathf.Clamp(iSkillState.PublicCoolingTime / 1, 0, 1);
            }
            else
            {
                innerImage.fillAmount = 0;
            }
            break;

        case EnumKeyContactType.Prap:
            PlayGoods playGoods = playerState.PlayerAllGoods.Where(temp => (int)temp.GoodsInfo.EnumGoodsType == keyContactStruct.id).FirstOrDefault();
            if (playGoods != null)
            {
                keyImage.sprite = playGoods.GetGoodsSprite;
            }
            else
            {
                keyImage.sprite = null;
            }
            innerImage.fillAmount = 0;
            break;

        case EnumKeyContactType.Action:
            keyImage.sprite       = keyContactStruct.Sprite;
            innerImage.fillAmount = 0;
            break;
        }
        keyImage.enabled = keyImage.sprite != null;
        r1Press          = false;
        r2Press          = false;
        l1Press          = false;
        l2Press          = false;
    }