public void FinalizeAfterLoad() { //Faction = FactionMgr.Get(FactionTemplateId); FemaleModel = UnitMgr.GetModelInfo(FemaleDisplayId); if (FemaleModel != null) { MaleModel = UnitMgr.GetModelInfo(MaleDisplayId); if (MaleModel != null) { // fix broken values if (FemaleModel.BoundingRadius < 0.1) { FemaleModel.BoundingRadius = MaleModel.BoundingRadius; } else if (MaleModel.BoundingRadius < 0.1) { MaleModel.BoundingRadius = FemaleModel.BoundingRadius; } if (FemaleModel.CombatReach < 0.1) { FemaleModel.CombatReach = MaleModel.CombatReach; } else if (MaleModel.CombatReach < 0.1) { MaleModel.CombatReach = FemaleModel.CombatReach; } ArchetypeMgr.BaseRaces[(uint)Id] = this; } } }
public static void InitInst() { if (m_Inst == null) { m_Inst = new UnitMgr(); } }
public void FinalizeAfterLoad() { FemaleModel = UnitMgr.GetModelInfo(FemaleDisplayId); if (FemaleModel == null) { return; } MaleModel = UnitMgr.GetModelInfo(MaleDisplayId); if (MaleModel == null) { return; } if (FemaleModel.BoundingRadius < 0.1) { FemaleModel.BoundingRadius = MaleModel.BoundingRadius; } else if (MaleModel.BoundingRadius < 0.1) { MaleModel.BoundingRadius = FemaleModel.BoundingRadius; } if (FemaleModel.CombatReach < 0.1) { FemaleModel.CombatReach = MaleModel.CombatReach; } else if (MaleModel.CombatReach < 0.1) { MaleModel.CombatReach = FemaleModel.CombatReach; } ArchetypeMgr.BaseRaces[(uint)Id] = this; }
public void FinalizeAfterLoad() { this.FemaleModel = UnitMgr.GetModelInfo(this.FemaleDisplayId); if (this.FemaleModel == null) { return; } this.MaleModel = UnitMgr.GetModelInfo(this.MaleDisplayId); if (this.MaleModel == null) { return; } if ((double)this.FemaleModel.BoundingRadius < 0.1) { this.FemaleModel.BoundingRadius = this.MaleModel.BoundingRadius; } else if ((double)this.MaleModel.BoundingRadius < 0.1) { this.MaleModel.BoundingRadius = this.FemaleModel.BoundingRadius; } if ((double)this.FemaleModel.CombatReach < 0.1) { this.FemaleModel.CombatReach = this.MaleModel.CombatReach; } else if ((double)this.MaleModel.CombatReach < 0.1) { this.MaleModel.CombatReach = this.FemaleModel.CombatReach; } ArchetypeMgr.BaseRaces[(uint)this.Id] = this; }
// Use this for initialization void Init(Vector3 startPos) { m_startPos = startPos; Position = m_startPos; m_uniMgr = GameMgr.Ins.m_unitMgr; m_endTarget = GameMgr.Ins.m_unitLocation.m_EnermyLocation.CommandCenter; m_DampOption.maxSpeed = 20; }
private void btnUnit_Click(object sender, EventArgs e) { lstInfo.DataSource = null; lblMessge.Text = btnUnit.Text; DataTable dt = UnitMgr.GetAll(); lstInfo.DataSource = dt; lstInfo.DisplayMember = dt.Columns[1].ToString();; lstInfo.ValueMember = dt.Columns[0].ToString(); }
//} /// <summary> /// 初始化计量单位列表 /// </summary> private void InitUnit() { DataTable dt = UnitMgr.GetAll(); if (dt != null) { cbxUnit.DataSource = dt; cbxUnit.DisplayMember = dt.Columns[1].ToString(); cbxUnit.ValueMember = dt.Columns[0].ToString(); } }
public override void OnDeath() { if (!IsLive) { return; } IsLive = false; Callback_OnDeathG?.Invoke(this); DeathRealTimer.Restart(DeathRealTime); DeathEffStartTimer.Restart(DeathEffStartTime); UnitMgr?.Despawn(this); base.OnDeath(); }
protected void Awake() { if (m_inst != null) { Destroy(gameObject); return; } m_inst = this; DBMgr.InitInst(); MapMgr.InitInst(); UnitMgr.InitInst(); EffectMgr.InitInst(); ElementMgr.InitInst(); ChipMgr.InitInst(); ObjectPool.InitInst(); CamMgr.InitInst(); m_audioBgm = transform.GetComponent <AudioSource> (); m_clipDeleteEnemy = Resources.Load <AudioClip> ("Sound/Bgm/EnemyDeleted"); m_clipGameover = Resources.Load <AudioClip> ("Sound/Bgm/Gameover"); }
/// <summary> /// Is called to initialize the object; usually after a set of other operations have been performed or if /// the right time has come and other required steps have been performed. /// </summary> public void FinalizeDataHolder() { if (string.IsNullOrEmpty(DefaultName)) { ContentMgr.OnInvalidDBData("NPCEntry has no name: " + this); return; } if (Titles == null) { Titles = new string[(int)ClientLocale.End]; } if (DefaultTitle == null) { DefaultTitle = ""; } if (SpellGroupId != 0 && NPCMgr.PetSpells != null) { var spells = NPCMgr.PetSpells.Get(SpellGroupId) ?? Spell.EmptyArray; foreach (var spell in spells) { AddSpell(spell); } } if (MinMana > MaxMana) { MaxMana = MinMana; } if (MaxDamage > 0) { if (MinDamage < 1) { MinDamage = 1; } if (MaxDamage < MinDamage) { MaxDamage = MinDamage; } } if (RangedMaxDamage > 0 && RangedMinDamage > 0) { if (RangedMaxDamage < RangedMinDamage) { RangedMaxDamage = RangedMinDamage; } if (RangedAttackTime == 0) { RangedAttackTime = AttackTime; } } AggroBaseRange = AggroBaseRangeDefault; NPCId = (NPCId)Id; DefaultDecayDelayMillis = _DefaultDecayDelayMillis; Family = NPCMgr.GetFamily(FamilyId); if (Type == CreatureType.NotSpecified || VehicleEntry != null) { IsIdle = true; } if (Type == CreatureType.NotSpecified && UnitFlags.HasFlag((UnitFlags.Passive | UnitFlags.NotSelectable))) { IsEventTrigger = true; IsIdle = false; } if (Resistances == null) { Resistances = new int[ItemConstants.MaxResCount]; } SetFlagIndices = Utility.GetSetIndices((uint)NPCFlags); // set/fix factions HordeFaction = FactionMgr.Get(HordeFactionId); AllianceFaction = FactionMgr.Get(AllianceFactionId); if (HordeFaction == null) { HordeFaction = AllianceFaction; HordeFactionId = AllianceFactionId; } else if (AllianceFaction == null) { AllianceFaction = HordeFaction; AllianceFactionId = HordeFactionId; } if (AllianceFaction == null) { ContentMgr.OnInvalidDBData("NPCEntry has no valid Faction: " + this); HordeFaction = AllianceFaction = NPCMgr.DefaultFaction; HordeFactionId = AllianceFactionId = (FactionTemplateId)HordeFaction.Template.Id; } // speeds if (SpeedFactor < 0.01) { SpeedFactor = 1; } if (WalkSpeed == 0) { WalkSpeed = NPCMgr.DefaultNPCWalkSpeed * SpeedFactor; } if (RunSpeed == 0) { RunSpeed = NPCMgr.DefaultNPCRunSpeed * SpeedFactor; } if (FlySpeed == 0) { FlySpeed = NPCMgr.DefaultNPCFlySpeed * SpeedFactor; } // Add all default spells if (FixedSpells != null) { foreach (var spell in FixedSpells) { AddSpell(spell); } } InstanceTypeHandlers = NPCMgr.GetNPCTypeHandlers(this); SpawnTypeHandlers = NPCMgr.GetNPCSpawnTypeHandlers(this); //ArrayUtil.PruneVals(ref DisplayIds); if (EquipmentId != 0) { Equipment = NPCMgr.GetEquipment(EquipmentId); } ModelInfos = new UnitModelInfo[DisplayIds.Length]; GeneratesXp = (Type != CreatureType.Critter && Type != CreatureType.None && !ExtraFlags.HasFlag(UnitExtraFlags.NoXP)); var x = 0; for (var i = 0; i < DisplayIds.Length; i++) { var did = DisplayIds[i]; if (did > 0) { var model = UnitMgr.GetModelInfo(did); if (model != null) { ModelInfos[x++] = model; } } } if (x == 0) { ContentMgr.OnInvalidDBData("NPCEntry has no valid DisplayId: {0} ({1})", this, DisplayIds.ToString(", ")); return; } if (TrainerTemplateId != 0) { if (!NPCMgr.TrainerSpellTemplates.ContainsKey(TrainerTemplateId)) { ContentMgr.OnInvalidDBData("NPCEntry has invalid TrainerTemplateId: {0} ({1})", this, TrainerTemplateId); } else { if (TrainerEntry == null) { TrainerEntry = new TrainerEntry(); } foreach (var trainerSpell in NPCMgr.TrainerSpellTemplates[TrainerTemplateId]) { TrainerEntry.AddSpell(trainerSpell); } } } if (AddonData != null) { AddonData.InitAddonData(this); } if (x < ModelInfos.Length) { Array.Resize(ref ModelInfos, x); } // add to container if (Id < NPCMgr.Entries.Length) { NPCMgr.Entries[Id] = this; } else { NPCMgr.CustomEntries[Id] = this; } ++NPCMgr.EntryCount; if (BrainCreator == null) { BrainCreator = DefaultBrainCreator; } if (NPCCreator == null) { NPCCreator = DefaultCreator; } }
protected virtual void Awake() { Time.timeScale = 1.0f; //unfreeze game if it was frozen from a previous game. Initialized = false; //faction stats are not ready, yet //Get components: CamMgr = FindObjectOfType(typeof(CameraController)) as CameraController; //Find the camera movement script. ResourceMgr = FindObjectOfType(typeof(ResourceManager)) as ResourceManager; //Find the resource manager script. BuildingMgr = FindObjectOfType(typeof(BuildingManager)) as BuildingManager; TaskMgr = FindObjectOfType(typeof(TaskManager)) as TaskManager; UnitMgr = FindObjectOfType(typeof(UnitManager)) as UnitManager; SelectionMgr = FindObjectOfType(typeof(SelectionManager)) as SelectionManager; GroupSelection = FindObjectOfType(typeof(UnitGroupSelection)) as UnitGroupSelection; PlacementMgr = FindObjectOfType(typeof(BuildingPlacement)) as BuildingPlacement; TerrainMgr = FindObjectOfType(typeof(TerrainManager)) as TerrainManager; MvtMgr = FindObjectOfType(typeof(MovementManager)) as MovementManager; UIMgr = FindObjectOfType(typeof(UIManager)) as UIManager; //Find the UI manager script. ErrorMessageMgr = FindObjectOfType(typeof(ErrorMessageHandler)) as ErrorMessageHandler; MinimapIconMgr = FindObjectOfType(typeof(MinimapIconManager)) as MinimapIconManager; AttackWarningMgr = FindObjectOfType(typeof(AttackWarningManager)) as AttackWarningManager; AttackMgr = FindObjectOfType(typeof(AttackManager)) as AttackManager; EffectPool = FindObjectOfType(typeof(EffectObjPool)) as EffectObjPool; UpgradeMgr = FindObjectOfType(typeof(UpgradeManager)) as UpgradeManager; InputMgr = FindObjectOfType(typeof(InputManager)) as InputManager; #if RTSENGINE_FOW FoWMgr = FindObjectOfType(typeof(FogOfWarRTSManager)) as FogOfWarRTSManager; #endif #if RTSENGINE_FOW if (FoWMgr) //only if there's a fog of war manager in the scene { FoWMgr.Init(this); } #endif CamMgr.Init(this); MinimapIconMgr?.Init(this); MvtMgr.Init(this); TaskMgr.Init(this); SelectionMgr.Init(this); GroupSelection.Init(this); PlacementMgr.Init(this); TerrainMgr.Init(this); UIMgr.Init(this); //initialize the UI manager. ErrorMessageMgr.Init(this); AttackWarningMgr?.Init(this); AttackMgr.Init(this); EffectPool.Init(this); UpgradeMgr.Init(this); ResourceMgr.Init(this); BuildingMgr.Init(this); UnitMgr.Init(this); InputMgr.Init(this); MultiplayerGame = false; //We start by assuming it's a single player game. if (!InitMultiplayerGame() && !InitSinglePlayerGame()) //if it's not neither a multiplayer nor a single player game { InitFactions(); //we're starting the game directly from the editor in the map scene, init factions directly } ResourceMgr.InitFactionResources(); //init resources for factions. InitCampaignGame(); //initialise a game where the player is coming from the campaign menu to play a mission SetPlayerFaction(); //pick the player faction ID. InitDefaultEntities(); //initialise the pre-spawned faction units and factions ResourceMgr.InitResources(); //init the pre-spawned resources. UnitMgr.OnFactionSlotsInitialized(); //init free units BuildingMgr.OnFactionSlotsInitialized(); //init free buildings if (MultiplayerGame) //if this is a multiplayer game { InputMgr.OnFactionSlotsInitialized(); //init spawnable prefabs and default entities in a multiplayer game } //In order to avoid having buildings that are being placed by AI players and units collide, we will ignore physics between their two layers: Physics.IgnoreLayerCollision(LayerMask.NameToLayer("Hidden"), LayerMask.NameToLayer("Unit")); //Set the amount of the active factions: activefactionsAmount = factions.Count; SetGameState(GameState.running); //the game state is now set to running UIMgr.PeaceTime.Toggle(peaceTime > 0.0f); //enable the peace time panel if there's actual peace time assigned //reaching this point means that all faction info/stats in the game manager are ready: Initialized = true; }
/// <summary> /// 删除选中的项 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDel_Click(object sender, EventArgs e) { if (lstInfo.SelectedIndex == -1) { untCommon.InfoMsg("请选择所要删除的项。"); return; } switch (this.lblMessge.Text) { case "增长方式": //删除增长方式 if (untCommon.QuestionMsg("确定要删除该项吗")) { if (AddTypeMgr.Del(int.Parse(lstInfo.SelectedValue.ToString()))) { btnAddType_Click(null, null); } else { untCommon.InfoMsg("删除失败"); } } break; case "资产名称": //删除资产名称 if (untCommon.QuestionMsg("确定要删除该项吗")) { if (EqNameMgr.Del(int.Parse(lstInfo.SelectedValue.ToString()))) { btnName_Click(null, null); } else { untCommon.InfoMsg("删除失败"); } } break; case "保管地点": //删除保管地点 if (untCommon.QuestionMsg("确定要删除该项吗")) { if (KeepPlaceMgr.Del(int.Parse(lstInfo.SelectedValue.ToString()))) { btnKeepPlace_Click(null, null); } else { untCommon.InfoMsg("删除失败"); } } break; case "计量单位": //删除计量单位 if (untCommon.QuestionMsg("确定要删除该项吗")) { if (UnitMgr.Del(int.Parse(lstInfo.SelectedValue.ToString()))) { btnUnit_Click(null, null); } else { untCommon.InfoMsg("删除失败"); } } break; case "清理方式": //删除清理方式 if (untCommon.QuestionMsg("确定要删除该项吗")) { if (ClearTypeMgr.Del(int.Parse(lstInfo.SelectedValue.ToString()))) { btnClearType_Click(null, null); } else { untCommon.InfoMsg("删除失败"); } } break; case "资产类别": //添加增长方式 if (untCommon.QuestionMsg("确定要删除该项吗")) { if (EqTypeMgr.Del(int.Parse(lstInfo.SelectedValue.ToString()))) { btnTyp_Click(null, null); } else { untCommon.InfoMsg("删除失败"); } } break; } }
/// <summary> /// 保存添加项 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { if (this.txtInput.Text.Trim() == "") { untCommon.InfoMsg("不能添加空相,请填写所要添加的内容。"); return; } if (this.txtInput.Text == "请输入新加项的内容") { untCommon.InfoMsg("请输入合法的新项"); return; } switch (this.lblMessge.Text) { case "增长方式": //添加增长方式 if (AddTypeMgr.Add(this.txtInput.Text)) { btnAddType_Click(null, null); txtInput.Text = ""; txtInput.Focus(); this.btnDel.Enabled = true; } else { untCommon.InfoMsg("添加失败"); } break; case "资产名称": ////添加资产名称 if (EqNameMgr.AddName(this.txtInput.Text)) { btnName_Click(null, null); txtInput.Text = ""; txtInput.Focus(); this.btnDel.Enabled = true; } else { untCommon.InfoMsg("添加失败"); } break; case "保管地点": //添加保管地点 if (KeepPlaceMgr.AddPlace(this.txtInput.Text)) { btnKeepPlace_Click(null, null); txtInput.Text = ""; txtInput.Focus(); this.btnDel.Enabled = true; } else { untCommon.InfoMsg("添加失败"); } break; case "计量单位": //添加计量单位 if (UnitMgr.Add(this.txtInput.Text)) { btnUnit_Click(null, null); txtInput.Text = ""; txtInput.Focus(); this.btnDel.Enabled = true; } else { untCommon.InfoMsg("添加失败"); } break; case "清理方式": //添加清理方式 if (ClearTypeMgr.Add(this.txtInput.Text)) { btnClearType_Click(null, null); txtInput.Text = ""; txtInput.Focus(); this.btnDel.Enabled = true; } else { untCommon.InfoMsg("添加失败"); } break; case "资产类别": //添加增长方式 if (EqTypeMgr.AddType(this.txtInput.Text)) { btnTyp_Click(null, null); txtInput.Text = ""; txtInput.Focus(); this.btnDel.Enabled = true; } else { untCommon.InfoMsg("添加失败"); } break; } }
void OnDestroy() { Ins = null; m_uniMgr = null; }
// Use this for initialization void Init(Transform startPos) { m_Transform.position = startPos.position; m_uniMgr = GameMgr.Ins.m_unitMgr; m_endTarget = GameMgr.Ins.m_unitLocation.m_armmyEndTarget.position; }