예제 #1
0
    public void AddBuff(int buff_id)
    {
        Config cMagicBuff   = ConfigPool.Load("MagicBuff");
        Config cTriggerBuff = ConfigPool.Load("TriggerBuff");
        Config cAuraBuff    = ConfigPool.Load("AuraBuff");

        if (cMagicBuff.ContainsKey(buff_id))
        {
            MagicBuff buff = new MagicBuff(this.role, buff_id);
            this.magic_buff_map.Add(buff_id, buff);
        }
        else if (cTriggerBuff.ContainsKey(buff_id))
        {
            TriggerBuff buff = new TriggerBuff(this.role, buff_id);
            this.trigger_buff_map.Add(buff_id, buff);
        }
        else if (cAuraBuff.ContainsKey(buff_id))
        {
            AuraBuff buff = new AuraBuff(this.role, buff_id);
            this.aura_buff_map.Add(buff_id, buff);
        }
        else
        {
            Log.Debug(string.Format("Buff Id:{0} Not Exist", buff_id));
        }
    }
예제 #2
0
    protected override void CustomInit()
    {
        Config terrain_config = ConfigPool.Load("Terrain");
        Config build_config   = ConfigPool.Load("Build");

        GameObject terrain_tab = Instantiate((GameObject)Resources.Load("Prefabs/UI/CustomScrollView"));

        foreach (KeyValuePair <object, ConfigItem> pair in terrain_config)
        {
            GameObject item = Instantiate((GameObject)Resources.Load("Prefabs/UI/CustomEditItem"));
            item.tag = GridTag.TERRAIN;
            item.GetComponent <CustomEditItem>().SetData(pair.Value);
            item.GetComponent <CustomEditItem>().OnClick = this.ItemClickCallBack;
            terrain_tab.GetComponent <CustomScrollView>().AddItem(item);
        }
        this.TabView.GetComponent <CustomTabView>().AddTab("地形", terrain_tab);

        GameObject build_tab = Instantiate((GameObject)Resources.Load("Prefabs/UI/CustomScrollView"));

        foreach (KeyValuePair <object, ConfigItem> pair in build_config)
        {
            GameObject item = Instantiate((GameObject)Resources.Load("Prefabs/UI/CustomEditItem"));
            item.tag = GridTag.BUILD;
            item.GetComponent <CustomEditItem>().SetData(pair.Value);
            item.GetComponent <CustomEditItem>().OnClick = this.ItemClickCallBack;
            build_tab.GetComponent <CustomScrollView>().AddItem(item);
        }
        this.TabView.GetComponent <CustomTabView>().AddTab("建筑", build_tab);

        GameObject tool_tab = Instantiate((GameObject)Resources.Load("Prefabs/UI/CustomScrollView"));

        this.TabView.GetComponent <CustomTabView>().AddTab("工具", tool_tab);

        this.TabView.GetComponent <CustomTabView>().SelectTab(1);
    }
예제 #3
0
    public bool ChangeState(int state_code)
    {
        if (this.CurState != null)
        {
            Config     cStateChange     = ConfigPool.Load("StateChange");
            ConfigItem cStateChangeItem = cStateChange[this.CurState.GetStateType()];
            if (cStateChangeItem == null)
            {
                Log.Error(string.Format("StateChange Config Id:{0} Not Exist", this.CurState.GetStateType()));
                return(false);
            }

            if (cStateChangeItem["CanChange"].Contains(state_code))
            {
                return(false);
            }
        }

        StateBase state = null;

        switch (state_code)
        {
        case StateType.IDLE:
        {
            state = new IdleState();
        }; break;

        case StateType.RUN:
        {
            state = new RunState();
        }; break;

        case StateType.ATTACK:
        {
            state = new AttackState();
        }; break;

        case StateType.DIE:
        {
            state = new DieState();
        }; break;

        default:
        {
            Log.Error("");
        }; break;
        }

        if (state == null || !state.CanChange(this.role))
        {
            return(false);
        }

        return(true);
    }
예제 #4
0
    public static string GetStr(int str_code)
    {
        Config config = ConfigPool.Load("Lang_" + SettingManager.GetLangCodeStr());

        if (config == null)
        {
            config = ConfigPool.Load("Lang_" + SettingManager.GetDefaultLangCodeStr());
        }
        ConfigItem config_item = config[str_code];

        if (config_item == null)
        {
            return("");
        }
        return(config_item["Value"].ToString());
    }
예제 #5
0
    public void ChangeBuildGrid(int grid_id, int build_id, float direction)
    {
        ConfigItem data = ConfigPool.Load("Build")[build_id];

        if (!this.list.ContainsKey(grid_id))
        {
            float x, z;
            this.GetXZ(grid_id, out x, out z);
            string     prefab     = "Prefabs/" + data["Prefab"];
            GameObject build_grid = GameObject.Instantiate((GameObject)Resources.Load(prefab));
            build_grid.name = "Build_" + grid_id;
            build_grid.transform.position = new Vector3(x, 0, z);
            build_grid.transform.SetParent(this.root.transform);
            this.list[grid_id] = build_grid;
        }
        this.list[grid_id].GetComponent <BuildGrid>().RefreshData(grid_id, data, direction);
    }
예제 #6
0
    public void ChangeTerrainGrid(int grid_id, int terrain_id)
    {
        ConfigItem data = ConfigPool.Load("Terrain")[terrain_id];

        if (!this.list.ContainsKey(grid_id))
        {
            float x, z;
            this.GetXZ(grid_id, out x, out z);
            string     prefab       = "Prefabs/" + data["Prefab"];
            GameObject terrain_grid = GameObject.Instantiate((GameObject)Resources.Load(prefab));
            terrain_grid.name = "Terrain_" + grid_id;
            terrain_grid.transform.position = new Vector3(x, 0, z);
            terrain_grid.transform.SetParent(this.root.transform);
            this.list[grid_id] = terrain_grid;
        }
        this.list[grid_id].GetComponent <TerrainGrid>().RefreshData(grid_id, data);
    }
예제 #7
0
    static void Main(string[] args)
    {
        try
        {
            int server_id = int.Parse(args[0]);

            Config     cServer     = ConfigPool.Load("Server");
            ConfigItem cServerItem = cServer[server_id];

            int        server_type = int.Parse(cServerItem["ServerType"].ToString());
            List <int> scene_list  = new List <int>();
            foreach (var scene_id in cServerItem["SceneList"])
            {
                scene_list.Add(int.Parse(scene_id.ToString()));
            }

            Server.GetInstance().Init(server_id, server_type, scene_list);
            if (server_type == ServerType.ROUTE)
            {
                string ip   = cServerItem["IP"].ToString();
                int    port = int.Parse(cServerItem["Port"].ToString());
                Server.GetInstance().Listen(ip, port);
            }
            else
            {
                foreach (var info in cServerItem["Connect"])
                {
                    string ip   = info[0].ToString();
                    int    port = int.Parse(info[1].ToString());
                    Server.GetInstance().Connect(ip, port);
                }
            }

            if (server_type != ServerType.ROUTE)
            {
                Server.GetInstance().RegisterToRoute();
            }
        }
        catch (Exception e)
        {
            Log.Error(e.ToString());
        }

        Thread.CurrentThread.Join();
        Server.GetInstance().Release();
    }
예제 #8
0
    public bool AddScene(int scene_id)
    {
        Config     cScene     = ConfigPool.Load("Scene");
        ConfigItem cSceneItem = cScene[scene_id];

        if (cSceneItem == null)
        {
            Log.Error(string.Format("Scene Id:{0} Not Exist", scene_id));
            return(false);
        }

        int   scene_idx = this.GetSceneIdx();
        Scene scene     = new Scene(scene_idx, scene_id);

        this.scene_map[scene_idx] = scene;

        Log.Debug(string.Format("Scene Id:{0} Idx:{1} Create", scene_id, scene_idx));

        return(true);
    }
예제 #9
0
    private void ParseAction()
    {
        Config     cSkill     = ConfigPool.Load("Skill");
        ConfigItem cSkillItem = cSkill[this.skill_id];

        foreach (JToken value in cSkillItem["Action"])
        {
            string   str         = value.ToString();
            string[] str_list    = str.Split(',');
            string   action_name = str_list[1];

            ActionBase action = null;
            switch (action_name)
            {
            case "Target":
            {
                int effect_id = int.Parse(str_list[2]);
                action = new TargetAction(this.role, effect_id);
            } break;

            case "Rect":
            {
                float face      = Single.Parse(str_list[2]);
                float dis       = Single.Parse(str_list[3]);
                int   effect_id = int.Parse(str_list[4]);
                action = new RectAction(this.role, face, dis, effect_id);
            } break;

            case "Delay":
            {
                int time = int.Parse(str_list[2]);
                action = new DelayAction(this.role, time);
            } break;
            }

            if (action != null)
            {
                this.action_list.Add(action);
            }
        }
    }