コード例 #1
0
ファイル: StageView.cs プロジェクト: sooncat/ProjectRougeLike
    void OnCreateHeroStartNode(object p1, object p2)
    {
        CatDebug.LogFunc();

        HeroData heroData     = (HeroData)p1;
        int      targetNodeId = (int)p2;

        if (_heroSelectNodes.ContainsKey(heroData.Id))
        {
            Dragable d = _heroSelectNodes[heroData.Id].GetComponentInChildren <Dragable>();
            d.SetEnable(false);
        }

        GameObject go = InsHeroNode(heroData, false);//这里的英雄还可能与其他英雄交换,故不添加特殊dragicon

        go.transform.SetParent(_stageNodeRootTrans);
        //go.GetComponent<Button>().onClick.AddListener(() => { });

        Dropable drop = go.AddComponent <Dropable>();

        drop.ActionId = heroData.Id;
        drop.OnDroped = DropOnHero;

        Transform target     = _nodeUIs[targetNodeId];
        UINode    targetNode = target.GetComponent <UINode>();

        go.transform.SetParent(targetNode.GetRef("HeroRoot"));

        _fightHeroNodes.Add(heroData.Id, go.transform);
    }
コード例 #2
0
    public static void StartRecord(string timerId, int type)
    {
        if (!_isStart)
        {
            return;
        }
        if (_timerStartIdRecords.Contains(timerId))
        {
            CatDebug.CWarning("StartRecord :Repeat timerID = " + timerId, CatLogType.CatTimer);
            return;
        }

        if (string.IsNullOrEmpty(timerId))
        {
            CatDebug.CError("StartRecord : Null/Empty timerID.", CatLogType.CatTimer);
            return;
        }

        if (_isShowDetail)
        {
            CatDebug.CLog("StartRecord : " + timerId + "," + type, CatLogType.CatTimer);
        }

        _lastLineTimerId   = timerId;
        _lastLineTimerType = type;

        _timerStartIdRecords.Add(timerId);
        _timerStartTimeRecords.Add(DateTime.Now);
    }
コード例 #3
0
ファイル: StageView.cs プロジェクト: sooncat/ProjectRougeLike
    void OnFightStateMapping(object p1, object p2)
    {
        CatDebug.LogFunc();

        Transform hsl = _stageNode.GetRef("HeroSelectList");

        hsl.gameObject.SetActive(false);

        Transform readyBtn = _stageNode.GetRef("ButtonReady");

        readyBtn.gameObject.SetActive(false);

        foreach (KeyValuePair <int, Transform> pair in _nodeUIs)
        {
            Dropable dropable = pair.Value.GetComponentInChildren <Dropable>();
            dropable.enabled = true;
        }

        Dictionary <int, FightHero> heroes = (Dictionary <int, FightHero>)p1;

        foreach (KeyValuePair <int, Transform> pair in _fightHeroNodes)
        {
            Dragable dragable = pair.Value.GetComponentInChildren <Dragable>();
            HeroData hd       = (HeroData)heroes[pair.Key].CreatureData;
            dragable.DragIcon = GameResSys.Instance.GetItem(hd.FightIcon);
        }

        //create hero show list
        CreateHeroShowList(heroes);
    }
コード例 #4
0
ファイル: GameMain.cs プロジェクト: sooncat/ProjectRougeLike
    protected override void GameStart()
    {
        CatDebug.Enable     = true;
        CatDebug.Enabletype = CatLogType.CatTimer | CatLogType.CatEvent;
        CatDebug.RegistLogTypeLabel(CatLogType.CatEvent, "Event");
        CatDebug.RegistLogTypeLabel(CatLogType.CatTimer, "Timer");

        InitSys <ViewSys>();
        InitSys <GameResSys>();
        ConfigSys.Instance.InitJsonConfig <GameStateConfig>("configs/gameconfig", "gamestateconfig.json");

        ConfigDataMgr.Instance.Load <HeroTableData>();
        ConfigDataMgr.Instance.Load <MonsterTableData>();
        ConfigDataMgr.Instance.Load <ItemTableData>();
        ConfigDataMgr.Instance.Load <PropertyDesTableData>();

        PlayerDataMgr.Instance.Init();
        FightDataMgr.Instance.Init();

        GameStateSys.Instance.InitState <StartState>();
        GameStateSys.Instance.InitState <LoginState>();
        GameStateSys.Instance.InitState <CityState>();
        GameStateSys.Instance.InitState <FightState>();

        AIMgr.Instance.Init();

        EventSys.Instance.AddEvent(FrameEvent.RegistResidentAssetBundle, GameConstants.AssetBundlePath + "view/loadingui");
        EventSys.Instance.AddEvent(FrameEvent.RegistResidentAssetBundle, GameConstants.AssetBundlePath + "tex/bg/loading");


        EventSys.Instance.AddEvent(LogicEvent.ChangeState, typeof(StartState));
    }
コード例 #5
0
 public virtual void Leave()
 {
     CatDebug.LogFuncInStack(1);
     EventSys.Instance.RemoveHander(this);
     EventSys.Instance.AddEvent(ViewEvent.LoadingShow);
     StartUnLoad();
 }
コード例 #6
0
    public static void EndRecord(string timerId)
    {
        if (!_isStart)
        {
            return;
        }
        int index = _timerStartIdRecords.IndexOf(timerId);

        if (index < 0)
        {
            CatDebug.CError("EndRecord : Null timerID = " + timerId, CatLogType.CatTimer);
            return;
        }
        TimeSpan ts = DateTime.Now - _timerStartTimeRecords[index];

        _timerStartIdRecords.RemoveAt(index);
        _timerStartTimeRecords.RemoveAt(index);
        if (_isShowDetail)
        {
            CatDebug.CLog("EndRecord : " + timerId + " Cost " + ts.TotalSeconds, CatLogType.CatTimer);
        }
        //_timerEndRecords.Add(timerId, ts.TotalMilliseconds);
        AddEndRecord(timerId, ts.TotalSeconds);
        if (timerId.Equals(_lastLineTimerId))
        {
            _lastLineTimerId = string.Empty;
        }
    }
コード例 #7
0
 protected virtual void OnUiLoaded(object p1, object p2)
 {
     EventSys.Instance.AddEvent(ViewEvent.LoadingUpdate, UiLoadPercent);
     CatDebug.LogFuncInStack(1);
     //EventSys.Instance.AddEvent(LogicEvent.UiLoadingUpdate, UiLoadPercent);
     OnAllPreLoaded();
 }
コード例 #8
0
    public override void Enter(GameStateParameter parameter)
    {
        CatDebug.LogFunc();

        base.Enter(parameter);

        EventSys.Instance.AddHander(InputEvent.LoginLogin, OnLoginEvent);
    }
コード例 #9
0
 public static void ShowDetail(bool isShow)
 {
     _isShowDetail = isShow;
     if (_isShowDetail)
     {
         CatDebug.CLog("CatTimer:ShowDetail(" + isShow + ")", CatLogType.CatTimer);
     }
 }
コード例 #10
0
 public static void Start()
 {
     if (_isShowDetail)
     {
         CatDebug.CLog("CatTimer:Start()", CatLogType.CatTimer);
     }
     _isStart = true;
 }
コード例 #11
0
 /// <summary>
 /// 同时结束Line计时
 /// </summary>
 public static void Stop()
 {
     if (_isShowDetail)
     {
         CatDebug.CLog("CatTimer:Stop()", CatLogType.CatTimer);
     }
     StopLineRecord();
     _isStart = false;
 }
コード例 #12
0
 void StartPreLoad()
 {
     CatDebug.LogFunc();
     foreach (GameStateConfig.PreLoadResConfig preLoadResConfig in GsDetail.PreLoadUi)
     {
         string path = preLoadResConfig.AssetBundle;
         EventSys.Instance.AddEvent(FrameEvent.AddPreLoadRes, path);
     }
     EventSys.Instance.AddEvent(FrameEvent.PreLoadStart);
 }
コード例 #13
0
        /// <summary>
        /// 清理,p1=true是彻底清理
        /// 可以在资源使用完成后false清理,
        /// 在切换游戏状态时可以true清理。
        /// </summary>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        void Clear(object p1, object p2)
        {
            CatDebug.LogFunc("isTrue=" + p1);
            bool isClearAll = (bool)p1;

            foreach (KeyValuePair <string, AssetBundle> pair in _assetCache)
            {
                pair.Value.Unload(isClearAll);
            }
            _assetCache.Clear();
        }
コード例 #14
0
    public virtual void Enter(GameStateParameter parameter)
    {
        CatDebug.LogFuncInStack(1);

        EventSys.Instance.AddHander(LogicEvent.SceneLoadEnd, OnSceneLoaded);
        EventSys.Instance.AddHander(FrameEvent.PreloadEnd, OnPreLoadEnd);
        EventSys.Instance.AddHander(LogicEvent.UiInsEnd, OnUiLoaded);

        EventSys.Instance.AddEvent(LogicEvent.EnterState, GetType());

        StartLoad();
    }
コード例 #15
0
 protected void StartInsUi()
 {
     CatDebug.LogFunc();
     if (GsDetail.PreLoadUi.Count > 0)
     {
         EventSys.Instance.AddEvent(LogicEvent.UiInsStart, GsDetail.PreLoadUi);
     }
     else
     {
         EventSys.Instance.AddEvent(LogicEvent.UiInsEnd);
     }
 }
コード例 #16
0
        /// <summary>
        /// 开始加载所有文件
        /// </summary>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        void OnStartPreLoad(object p1, object p2)
        {
            CatDebug.LogFunc();
            if (_resPath.Count == 0)
            {
                EventSys.Instance.AddEvent(FrameEvent.PreloadEnd);
            }
            PrepareResDependencies(_resPath.ToArray());

            //start load first layer res
            _nowLevel = 0;
            StartLoadResInLayer(_nowLevel);
        }
コード例 #17
0
    public virtual void Init()
    {
        CatDebug.LogFunc();
        GameStateConfig GsConfig = ConfigSys.Instance.GetConfig <GameStateConfig>();


        GsConfig.GameStateDetails.TryGetValue(GetName(), out GsDetail);

        if (GsDetail == null)
        {
            throw new KeyNotFoundException(GetName());
        }
    }
コード例 #18
0
    protected void StartLoadScene()
    {
        CatDebug.LogFunc();
        string sceneName = GsDetail.SceneName;

        if (!string.IsNullOrEmpty(sceneName))
        {
            EventSys.Instance.AddEvent(LogicEvent.SceneLoadStart, sceneName, false);
        }
        else
        {
            EventSys.Instance.AddEvent(LogicEvent.SceneLoadEnd, sceneName);
        }
    }
コード例 #19
0
    void CreateFightHeros(object p1, object p2)
    {
        Dictionary <int, int> selectedHeros = (Dictionary <int, int>)p1;

        _heros = new Dictionary <int, FightHero>();

        foreach (KeyValuePair <int, int> pair in selectedHeros)
        {
            Hero      hero  = PlayerDataMgr.Instance.GetHero(pair.Key);
            FightHero fHero = new FightHero(hero);
            fHero.NowNodeId = pair.Value;
            _heros.Add(fHero.Id, fHero);
        }

        CatDebug.LogFunc();
    }
コード例 #20
0
    void OnUseItemToHero(object p1, object p2)
    {
        int targetHeroId = (int)p1;
        int itemId       = (int)p2;

        CatDebug.LogFunc("targetHeroId = " + targetHeroId + ", itemId = " + itemId);

        FightHero originHero = FightDataMgr.Instance.GetHero(_nowHeroId);
        FightHero targetHero = FightDataMgr.Instance.GetHero(targetHeroId);
        Item      item       = targetHero.Items[itemId];

        if (item.Id == 1)
        {
            int nowHp = targetHero.CreatureData.Hp.Value;
            if (nowHp >= 0)
            {
                targetHero.CreatureData.Hp.Value = System.Math.Min(nowHp + 100, targetHero.CreatureData.HpMax.Value);
                originHero.DelItem(item.Id, 1);
                EventSys.Instance.AddEvent(ViewEvent.FightUpdateAllHeroState, _heros);
                EventSys.Instance.AddEvent(ViewEvent.FightHeroHpSupply, targetHero.Id, 100);

                originHero.IsActioned = true;
                CheckChangeTurnToEnemy();
            }
        }
        else if (item.Id == 2)
        {
            int nowMp = targetHero.CreatureData.Mp.Value;
            targetHero.CreatureData.Mp.Value = System.Math.Min(nowMp + 100, targetHero.CreatureData.MpMax.Value);
            originHero.DelItem(item.Id, 1);
            EventSys.Instance.AddEvent(ViewEvent.FightUpdateAllHeroState, _heros);
            EventSys.Instance.AddEvent(ViewEvent.FightHeroMpSupply, targetHero.Id, 100);

            originHero.IsActioned = true;
            CheckChangeTurnToEnemy();
        }
        else
        {
            EventSys.Instance.AddEvent(ViewEvent.FightShowTipNotSupportYet);
        }
    }
コード例 #21
0
    void StartAI(object p1, object p2)
    {
        CatDebug.LogFunc();

        Dictionary <int, FightHero> heroes = (Dictionary <int, FightHero>)p1;
        List <Enemy> enemies = (List <Enemy>)p2;

        foreach (Enemy enemy in enemies)
        {
            if (enemy.CreatureData.Hp.Value > 0)
            {
                //目前AI只有一种行为就是普通攻击
                FightHero targetHero = SelectHero(heroes);
                if (targetHero != null)
                {
                    EventSys.Instance.AddEventNow(AiInputEvent.Attack, enemy, targetHero);
                }
            }
        }

        EventSys.Instance.AddEvent(AiInputEvent.AiActionEnd);
    }
コード例 #22
0
    public void OnDrop(PointerEventData eventData)
    {
        //if (eventData.pointerDrag != null)
        //{
        //Image img = eventData.pointerDrag.GetComponent<Image>();
        //if (img != null)
        //{
        //    GetComponent<Image>().sprite = img.sprite;
        //    GetComponent<Image>().color = new Color(1, 1, 1, 1);//我刚开始把图片设为了透明
        //}
        //}

        CatDebug.LogFunc(eventData.pointerDrag.name);
        if (Dragable.StartDrag)
        {
            if (OnDroped != null)
            {
                OnDroped(ActionId);
            }

            Dragable.StartDrag = false;
        }
    }
コード例 #23
0
 public static void PrintType(int type)
 {
     CatDebug.CLog(GetTypeDetail(type).ToString(), CatLogType.CatTimer);
 }
コード例 #24
0
    /// <summary>
    /// 将英雄拖拽到地图节点上
    /// </summary>
    /// <param name="p1"></param>
    /// <param name="p2"></param>
    void OnFightDragOnNode(object p1, object p2)
    {
        int heroId       = (int)p1;
        int targetNodeId = (int)p2;

        CatDebug.LogFunc(" p1 = " + heroId + ", p2 = " + targetNodeId);

        switch (_fState)
        {
        case FSubState.SelectHero:
            //拖拽一个英雄到一个无人的起始节点上
            Hero h = PlayerDataMgr.Instance.GetHero(heroId);
            if (h != null)
            {
                if (_selectedHeros.ContainsKey(h.Id))       //从另一个起始节点拖拽到新起始节点,即替换英雄起始位置
                {
                    _selectedHeros[h.Id] = targetNodeId;
                    EventSys.Instance.AddEvent(ViewEvent.ResetHeroStartNode, heroId, targetNodeId);
                }
                else           //从英雄列表中拖拽到起始节点
                {
                    _selectedHeros.Add(h.Id, targetNodeId);
                    EventSys.Instance.AddEvent(ViewEvent.CreateHeroStartNode, h.CreatureData, targetNodeId);
                }
            }
            break;

        case FSubState.Mapping:

            BaseStageNode node = _stageConfig.GetNode(targetNodeId);

            if (node.IsPassed)
            {
                EventSys.Instance.AddEvent(ViewEvent.ShowTipNodePassed);
                return;
            }

            FightHero     fh       = FightDataMgr.Instance.GetHero(heroId);
            BaseStageNode heroNode = _stageConfig.GetNode(fh.NowNodeId);
            if (!heroNode.NextNodes.Contains(targetNodeId))
            {
                EventSys.Instance.AddEvent(ViewEvent.ShowTipNotNextNode);
                return;
            }

            string nodeType = node.NodeType;

            if (nodeType.Equals(typeof(StageNodeFight).Name))
            {
                EventSys.Instance.AddEvent(LogicEvent.StartFightRound, new [] { heroId }, targetNodeId);
            }
            else if (nodeType.Equals(typeof(StageNodeReward).Name))
            {
                Reward r = FightDataMgr.Instance.GetReward(targetNodeId);
                EventSys.Instance.AddEvent(ViewEvent.ShowNodeRewardGet, r, new [] { targetNodeId, heroId });
            }
            else if (nodeType.Equals(typeof(StageNodeSafe).Name))
            {
                fh.NowNodeId = targetNodeId;
                EventSys.Instance.AddEvent(ViewEvent.GetSafeReturnToStage, fh);
            }
            break;
        }
    }
コード例 #25
0
 protected virtual void OnAllPreLoaded()
 {
     CatDebug.LogFuncInStack(1);
     EventSys.Instance.AddEvent(ViewEvent.LoadingHide);
 }