Пример #1
0
        //add
        private void UnitSelection_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (UnitSelection.SelectedIndex == -1)
            {
                return;
            }

            int i = UnitSelection.SelectedIndex;

            UnitSetting tempsetting = new UnitSetting()
            {
                Area = unitSettings.Area[i], TypeName = unitSettings.TypeName[i], ExclusiveArea = unitSettings.ExclusiveArea[i], MinWidth = unitSettings.MinWidth[i], MaxWidth = unitSettings.MaxWidth[i]
            };

            UnitSetting[] temp = new UnitSetting[Units.Items.Count];
            Units.Items.CopyTo(temp, 0);


            if (temp.Where(n => n.TypeName == tempsetting.TypeName).ToList().Count != 0)
            {
                return;
            }

            int index = temp.Where(n => n.Area < tempsetting.Area).Count();

            Units.Items.Insert(index, tempsetting);

            UnitSelection.SelectedIndex = -1;

            UnitSetup();
        }
Пример #2
0
        //remove
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            if (btn.DataContext is UnitSetting)
            {
                UnitSetting deleteme = (UnitSetting)btn.DataContext;
                Units.Items.Remove(deleteme);
            }

            UnitSetup();
        }
Пример #3
0
    ///
    //public Unit(Unit unit)
    //{

    //}
    public override void Init(bool UserSoure = true)
    {
        Name = Content["0"];

        if (Setting == null)
        {
            // if (Content.ContainsKey("Setting"))
            //     Setting = GameDataTool.GetOrNewGameDataByStatic<UnitSetting>(false, Content["Setting"]);
            // else SaveValue("Setting", "");
            Setting = InitParaByStatic <UnitSetting>(false, "Setting");
        }
        else
        {
            SaveValue("Setting", Setting.Name);
        }

        //if (Content.ContainsKey("King") && UserSoure) { this.king = Game.DynamicDataManager.GetGameData<King>(Content["King"]); } else { SaveValue("King", ""); }
        if (UserSoure)
        {
            king = InitParaByDynamic <King>(UserSoure, "king");
        }

        //if (Content.ContainsKey("Team") && UserSoure) { this.team = Game.DynamicDataManager.GetGameData<Team>(Content["Team"]); } else { SaveValue("Team", ""); }
        if (UserSoure)
        {
            team = InitParaByDynamic <Team>(UserSoure, "Team");
        }


        if (king != null && team != null)
        {
            if (team.army.king != king)
            {
                throw new System.Exception("team.army.king != king");
            }
        }

        //       if (this.king == null && this.team != null)
        //         this.king = this.team.army.king;

        // if (Content.ContainsKey("Count")) { Count = int.Parse(Content["Count"]); } else { SaveValue("Count", "0"); };
        // if (Content.ContainsKey("Injury")) { Injury = int.Parse(Content["Injury"]); } else { SaveValue("Injury", "0"); };
        // if (Content.ContainsKey("Morale")) { Morale = int.Parse(Content["Morale"]); } else { SaveValue("Morale", "0"); };
        Count  = InitIntValue("Count");
        Injury = InitIntValue("Injury");
        Morale = InitIntValue("Morale");
    }
        public static PlayerUnitSettings fromEntity(APlayableEntity entity, IUnitSettingCollectionItem[] collection)
        {
            List<UnitSetting> tempSettings = new List<UnitSetting>();
            UnitSetting tempSetting;
            foreach (IUnitSettingCollectionItem item in collection)
            {
                tempSetting = new UnitSetting();
                tempSetting.Item = item;
                tempSetting.Enabled = UnitPreference.getPreference(entity, item.Name);

                tempSettings.Add(tempSetting);
            }

            PlayerUnitSettings playerUnitSettings = new PlayerUnitSettings();
            playerUnitSettings.UnitSettings = tempSettings;

            return playerUnitSettings;
        }
Пример #5
0
    public GameData CreateGameData(GameData item, bool init = true, bool UserSoure = true) //复制  未知类型时
    {
        GameData data = null;

        if (item == null)
        {
            return(null);
        }
        switch (item.DataType)
        {
        case GameDataType.King: data = new King(item, init, UserSoure); break;

        case GameDataType.Army: data = new Army(item, init, UserSoure); break;

        case GameDataType.Team: data = new Team(item, init, UserSoure); break;

        case GameDataType.Hero: data = new Hero(item, init, UserSoure); break;

        case GameDataType.TeamBuff: data = new TeamBuff(item, init, UserSoure); break;

        case GameDataType.UnitBuff: data = new UnitBuff(item, init, UserSoure); break;

        case GameDataType.Skill: data = new Skill(item, init, UserSoure); break;

        case GameDataType.City: data = new City(item, init, UserSoure); break;

        case GameDataType.UnitSetting: data = new UnitSetting(item, init, UserSoure); break;

        case GameDataType.Unit: data = new Unit(item, init, UserSoure); break;

        case GameDataType.ConversationData: data = new CommunicationData(item, init, UserSoure); break;

        case GameDataType.Other: data = new GameData(item); break;

        case GameDataType.DynamicGameSetting: data = new DynamicGameSetting(item); break;

        case GameDataType.StaticGameSetting: data = new StaticGameSetting(item); break;

        default: break;
        }
        return(data);
    }
Пример #6
0
    public GameData CreateGameData(GameDataType type, string name) //这是为方便GameDataEditWindow  未知类型时
    {
        GameData data = null;

        if (string.IsNullOrEmpty(name))
        {
            return(null);
        }
        switch (type)
        {
        case GameDataType.King: data = new King(name); break;

        case GameDataType.Army: data = new Army(name); break;

        case GameDataType.Team: data = new Team(name); break;

        case GameDataType.Hero: data = new Hero(name); break;

        case GameDataType.TeamBuff: data = new TeamBuff(name); break;

        case GameDataType.UnitBuff: data = new UnitBuff(name); break;

        case GameDataType.Skill: data = new Skill(name); break;

        case GameDataType.City: data = new City(name); break;

        case GameDataType.UnitSetting: data = new UnitSetting(name); break;

        case GameDataType.Unit: data = new Unit(name); break;

        case GameDataType.ConversationData: data = new CommunicationData(name); break;

        case GameDataType.Other: data = new GameData(GameDataType.Other, name); break;

        case GameDataType.DynamicGameSetting: data = new DynamicGameSetting(name); break;

        case GameDataType.StaticGameSetting: data = new StaticGameSetting(name); break;

        default: break;
        }
        return(data);
    }
Пример #7
0
    public UnitSystems(Contexts contexts, UnitSetting setting, GameObject characterContainer, GameUI ui, SystemController syscon) : base("Unit System")
    {
        _contexts = contexts;
        _ui       = ui;
        _syscon   = syscon;

        Add(new PlayerCharacterCreatingSystem(contexts));
        Add(new CharacterDataLoadingSystem(contexts, setting.CharacterSetting));
        Add(new BossDataLoadingSystem(contexts, setting.BossSetting));
        Add(new SkillResourceLoadingSystem(contexts));
        Add(new UnitViewCreatingSystem(contexts, characterContainer));
        Add(new CharacterGameObjectRenameSystem(contexts));
        Add(new DeadSystem(contexts));
        Add(new UnitPositionRenderingSystem(contexts));
        Add(new LocalCharacterFlagSystem(contexts));
        Add(new LocalCharacterHpBarSystem(contexts, ui.LocalPlayerStatus.HpBar));
        Add(new LocalCharacterStatusSetupSystem(contexts, ui.LocalPlayerStatus));
        Add(new LocalCharacterStatusRenderingSystem(contexts, ui.LocalPlayerStatus));
        Add(new TargetUnitStatusDisplaySystem(contexts, ui.TargetPlayerStatus));
        Add(new RenderDeadSpriteSystem(contexts, setting));
        Add(new RenderResurrectionSpriteSystem(contexts));
        CreateBossSystems();
    }
Пример #8
0
        //set
        private void UnitSetup()
        {
            Width_Combo.Items.Clear();
            UnitSetting[] temp = new UnitSetting[Units.Items.Count];
            Units.Items.CopyTo(temp, 0);

            if (temp.Length == 0)
            {
                //선택 x ?
                return;
            }


            //최대값의최소값
            double widthMax = temp.Select(n => n.MaxWidth).Min();
            //최소값의최대값
            double widthMin = temp.Select(n => n.MinWidth).Max();
            //최대값의 최소값, 최소값의 최대값 의 평균
            double widthAvrg = (widthMax + widthMin) / 2;

            Width_Combo.Items.Add(widthMin);
            Width_Combo.Items.Add(widthAvrg);
            Width_Combo.Items.Add(widthMax);
        }
Пример #9
0
 public RenderDeadSpriteSystem(Contexts contexts, UnitSetting unitSetting) : base(contexts.unit)
 {
     this._deadSprite = unitSetting.DeadSprite;
 }
Пример #10
0
 public Unit(string name, UnitSetting Setting = null, bool UserSoure = true) : base(GameDataType.Unit, name)
 {
     this.Setting = Setting;
     Init(UserSoure);
 }