public virtual bool RemoveFromFormation(FormationType sourceFormationType, ISimpleStub unitsToRemove) { if (!HasFormation(sourceFormationType)) { return(false); } // Make sure there are enough units var sourceFormation = Data[sourceFormationType]; var allUnitsToRemove = unitsToRemove.ToUnitList(); foreach (var unit in allUnitsToRemove) { ushort count; if (!sourceFormation.TryGetValue(unit.Type, out count) || count < unit.Count) { return(false); } } foreach (var unit in unitsToRemove.SelectMany(formation => formation)) { Data[sourceFormationType].Remove(unit.Key, unit.Value); } return(true); }
public Formation(FormationType Type, BotEntity Lead, uint Pos, List<BotEntity> members) { _formationType = Type; _leader = Lead; _position = Pos; _members = members; }
public void Init(int formationIndex, int formationSize, FormationType formationType, float formationScaleFactor = 1) { this.formationIndex = formationIndex; this.formationType = formationType; this.formationScaleFactor = formationScaleFactor; this.formationSize = formationSize; }
private void OnEnable() { allBoids = new List <FBoid>(); if (boidsInFormation % 2 == 0) { boidsInFormation++; } for (int i = 0; i < boidsInFormation; i++) { FBoid currentBoid = Instantiate(boid, transform.position, transform.rotation).GetComponent <FBoid>(); allBoids.Add(currentBoid); } Debug.Log("<color=green>" + gameObject.name + "</color><color=blue> is now attacking: </color><color=red>" + meAttack.ToString() + "</color><color=blue> which is at position: </color><color=yellow>" + seekPos.ToString() + "</color>"); if (meAttack == Enemies.Dog || meAttack == Enemies.Man) { formationType = FormationType.V; } if (meAttack == Enemies.Cat) { formationType = FormationType.Circle; } rb = GetComponent <Rigidbody>(); }
public Formation(Formation cloner) { _formationType = cloner.FormationType; _leader = cloner.Leader; _position = cloner.Position; _members = cloner.Members; }
public void SetFormationMode(FormationType formationType) { if (formationModeIndicator) { formationModeIndicator.SetSprite(formationType == FormationType.Manual ? manualFormationIcon : autoFormationIcon); } }
public AttackCombatUnit(uint id, uint battleId, ITroopObject troopObject, FormationType formation, ushort type, byte lvl, ushort count, UnitFactory unitFactory, IBattleFormulas battleFormulas, Formula formula, ITileLocator tileLocator, IDbManager dbManager) : base(id, battleId, battleFormulas, dbManager) { this.troopObject = troopObject; this.formation = formation; this.type = type; this.count = count; this.formula = formula; this.tileLocator = tileLocator; this.lvl = lvl; stats = troopObject.Stub.Template[type]; LeftOverHp = stats.MaxHp; eachUnitUpkeep = unitFactory.GetUnitStats(type, lvl).Upkeep; }
public DefenseCombatUnit(uint id, uint battleId, ITroopStub stub, FormationType formation, ushort type, byte lvl, ushort count, IBattleFormulas battleFormulas, Formula formula, UnitFactory unitFactory, IDbManager dbManager) : base(id, battleId, battleFormulas, dbManager) { troopStub = stub; this.formation = formation; this.type = type; this.count = count; this.formula = formula; this.lvl = lvl; stats = stub.Template[type]; leftOverHp = stats.MaxHp; eachUnitUpkeep = unitFactory.GetUnitStats(type, lvl).Upkeep; }
private void updatePositional(FormationType formation) { if (Leader._followerToPositionId.Count < Leader._followers.Count || Leader._followers.Count <= _registrationId) { return; } var target = Leader.followerPositionFor(formation, _registrationId); if (Vector3.Distance(target, transform.position) < 0.2f) { if (_isRegrouping) { _isRegrouping = false; Message("ToExitProcess"); } return; } if ((ShouldRun(target) || Leader._isRunning) && (_isRunning || canRun)) { Message("ToRunTo", target); } else { Message("ToWalkTo", target); } }
private Vector3 followerPositionAt(FormationType formation, int index) { switch (formation) { case FormationType.Square: { var right = Vector3.Cross(Direction, Vector3.up); Vector3 position; switch (index) { case 0: position = transform.position - (right + Direction).normalized * Square.Distance; break; case 1: position = transform.position - (-right + Direction).normalized * Square.Distance; break; default: position = transform.position - Direction * Square.Distance * index; break; } var ideal = position; AIUtil.GetClosestStandablePosition(ref position); var closest = Vector3.zero; var hasClosest = false; var minDist = 0f; for (int i = 0; i < _followers.Count; i++) { var dist = Vector3.Distance(_followers[i].transform.position, ideal); if (_followers[i]._obstacle != null && _followers[i]._obstacle.enabled && dist <= _followers[i]._obstacle.radius + float.Epsilon) { dist = 0; } if (!hasClosest || dist < minDist) { closest = _followers[i].transform.position; minDist = dist; hasClosest = true; } } if (hasClosest && Vector3.Distance(position, ideal) > minDist) { position = closest; } return(position); } case FormationType.Line: return(_line[index]); default: Debug.Assert(false); return(Vector3.zero); } }
public void ChangeFormation(FormationType originalFormation, FormationType newFormation) { lock (objLock) { CheckUpdateMode(); if (!Data.ContainsKey(originalFormation)) { throw new ArgumentException("originalFormation does not exist"); } if (!AddFormation(newFormation)) { throw new Exception("New formation already exists"); } foreach (var unit in Data[originalFormation]) { AddUnit(newFormation, unit.Key, unit.Value); } RemoveFormation(originalFormation); FireUnitUpdated(); } }
public IFormation this[FormationType type] { get { return(Data[type]); } }
public Formation(Unit unit, FormationRole formationRole, FormationType formationType) { InitUnit(unit); this.formationRole = formationRole; this.formationType = formationType; }
public void SetFormationMode(FormationType formationType) { if (formationModeIndicator) { // uncomment the line below if needed formationModeIndicator.SetText(formationType == FormationType.Manual ? "Manual Formation" : "Auto Formation"); } }
public Formation(FormationType type, int priority, List<int> groupEntities, float position, int speed) { _type = type; _priority = priority; _groupEntities = groupEntities; _position = position; _speed = speed; _storedSpeed = _speed; }
public override bool RemoveFromFormation(FormationType sourceFormationType, ISimpleStub unitsToRemove) { BeginUpdate(); var result = base.RemoveFromFormation(sourceFormationType, unitsToRemove); EndUpdate(); return(result); }
void ChangeFormation(FormationType newFormationType) { if (formationType == newFormationType) { return; } formationType = newFormationType; CreateNewFormation(); }
public FleetState(FleetState orig) { Formation = orig.Formation; SearchResult = orig.SearchResult; Ships = new ShipState[] { new ShipState(orig.Ships[0]), new ShipState(orig.Ships[1]), new ShipState(orig.Ships[2]), new ShipState(orig.Ships[3]), new ShipState(orig.Ships[4]), new ShipState(orig.Ships[5]) }; }
public SpawnSpiderGroupWaveAction(string spPoint, List <AIAction> leader, List <AIAction> attack, List <AIAction> infect, FormationType form, int[] col, float iniDel = 0f, SpiderAIBehaviour.SpawnAnimation spawnAnim = SpiderAIBehaviour.SpawnAnimation.FLOOR) { spawnPointName = spPoint; leaderActions = leader; attackActions = attack; infectActions = infect; initialDelay = iniDel; formation = form; colors = col; spawnAnimation = spawnAnim; spiderIndex = 0; enemyMng = rsc.enemyMng; switch (formation) { case FormationType.ROLLING: followersActions = new List <AIAction>[4] { null, enemyMng.rolling, enemyMng.rolling, enemyMng.rolling }; break; case FormationType.THREE_FRONT: followersActions = new List <AIAction>[4] { null, enemyMng.three_front_1, enemyMng.three_front_2, enemyMng.three_front_3 }; break; case FormationType.THREE_BACK: followersActions = new List <AIAction>[4] { null, enemyMng.three_back_1, enemyMng.three_back_2, enemyMng.three_back_3 }; break; case FormationType.TRIANGLE: followersActions = new List <AIAction>[5] { null, enemyMng.triangle_1, enemyMng.triangle_2, enemyMng.triangle_3, enemyMng.triangle_4 }; break; case FormationType.QUAD: followersActions = new List <AIAction>[5] { null, enemyMng.quad_1, enemyMng.quad_2, enemyMng.quad_3, enemyMng.quad_4 }; break; default: break; } groupInfo = new EnemyGroupInfo(); groupInfo.followersCount = followersActions.Length - 1; groupInfo.leaderActionIndex = 0; }
public int UpkeepForFormation(FormationType type) { IFormation formation; if (!TryGetValue(type, out formation)) { return(0); } return(formation.Sum(kvp => kvp.Value * City.Template[kvp.Key].Upkeep)); }
public FormationData GetFormation(FormationType _type) { for (int i = 0; i < List.Length; i++) { if (_type == List[i].Type) { return(List[i]); } } return(List[0]); }
public CityEngageDefensePassiveAction(uint cityId, uint troopObjectId, FormationType formationType, BattleProcedure battleProcedure, CityBattleProcedure cityBattleProcedure, IGameObjectLocator gameObjectLocator) : this(battleProcedure, cityBattleProcedure, gameObjectLocator) { this.cityId = cityId; this.troopObjectId = troopObjectId; this.formationType = formationType; }
private Vector3 followerPositionFor(FormationType formation, int index) { if (_followerToPositionId.Count > index) { return(followerPositionAt(formation, _followerToPositionId[index])); } else { Debug.Assert(false); return(followerPositionAt(formation, index)); } }
public Formation getFormation(FormationType formationType) { foreach (Formation formation in _formations) { if (formation.type == formationType) { return formation; } } return null; }
public void AddAllToFormation(FormationType formation, ISimpleStub unitsToAdd) { lock (objLock) { CheckUpdateMode(); foreach (var unit in unitsToAdd.ToUnitList()) { AddUnit(formation, unit.Type, unit.Count); } } }
public void OnButtonC() { if (Selected) { int result = (int)FormationType; result++; if (!System.Enum.IsDefined(typeof(FormationType), result)) { result = 0; } FormationType = (FormationType)result; } }
public DefenseCombatUnit(uint id, uint battleId, ITroopStub stub, FormationType formation, ushort type, byte lvl, ushort count, decimal leftOverHp, IBattleFormulas battleFormulas, Formula formula, UnitFactory unitFactory, IDbManager dbManager) : this(id, battleId, stub, formation, type, lvl, count, battleFormulas, formula, unitFactory, dbManager) { this.leftOverHp = leftOverHp; }
public void AddToAttack(ushort type, byte lvl, ushort count, FormationType formation) { using (Concurrency.Current.Lock(city)) { city.BeginUpdate(); city.Template[type] = Ioc.Kernel.Get <UnitFactory>().GetUnitStats(type, lvl); if (city.Template[type] == null) { throw new Exception("Unit type not found!"); } city.EndUpdate(); AttackStub.BeginUpdate(); AttackStub.AddUnit(formation, type, count); AttackStub.EndUpdate(); } }
public virtual void AddUnit(FormationType formationType, ushort type, ushort count) { if (count <= 0) { return; } IFormation formation; if (!Data.TryGetValue(formationType, out formation)) { formation = new Formation(formationType); Data.Add(formationType, formation); } formation.Add(type, count); }
public void Set(WeakpointFormation other) { _type = other._type; _rotateSpeed = other._rotateSpeed; _distance = other._distance; _followSpeed = other._followSpeed; _transistionTime = other._transistionTime; _delay = other._delay; _animationName = other._animationName; _pivot = other._pivot; _customTrackPoint = new Transform[other._customTrackPoint.Length]; for (int i = 0; i < _customTrackPoint.Length; i++) { _customTrackPoint[i] = other._customTrackPoint[i]; } }
public DefenseCombatUnit[] CreateDefenseCombatUnit(IBattleManager battleManager, ITroopStub stub, FormationType formation, ushort type, ushort count) { var battleFormulas = kernel.Get <IBattleFormulas>(); var formula = kernel.Get <Formula>(); var unitFactory = kernel.Get <UnitFactory>(); var dbManager = kernel.Get <IDbManager>(); IBaseUnitStats template = stub.City.Template[type]; BattleStats stats = stub.Template[type]; var groupSize = (from effect in stub.City.Technologies.GetEffects(EffectCode.UnitStatMod) where ((string)effect.Value[0]).ToLower() == "groupsize" && battleFormulas.UnitStatModCheck(stats.Base, TroopBattleGroup.Defense, (string)effect.Value[3]) select(int) effect.Value[2]).DefaultIfEmpty().Max() + stats.Base.GroupSize; var units = new DefenseCombatUnit[(count - 1) / groupSize + 1]; int i = 0; do { ushort size = (ushort)(groupSize > count ? count : groupSize); DefenseCombatUnit newUnit = new DefenseCombatUnit(battleManager.GetNextCombatObjectId(), battleManager.BattleId, stub, formation, type, template.Lvl, size, battleFormulas, formula, unitFactory, dbManager); units[i++] = newUnit; count -= size; }while (count > 0); return(units); }
public bool AddFormation(FormationType type) { lock (objLock) { CheckUpdateMode(); if (Data.ContainsKey(type)) { return(false); } var formation = new Formation(type); formation.OnUnitUpdated += FormationOnUnitUpdated; Data.Add(type, formation); FireUnitUpdated(); } return(true); }
public override void AddUnit(FormationType formationType, ushort type, ushort count) { if (count <= 0) { return; } lock (objLock) { IFormation formation; if (Data.TryGetValue(formationType, out formation)) { formation.Add(type, count); } FireUnitUpdated(); } }
public Unit(string unitId, FactionName unitFaction, EncounterPosition rallyPoint, UnitOrder standingOrder, FormationType unitFormation, FormationFacing unitFacing) { this.UnitId = unitId; this.UnitFaction = unitFaction; this.LeftFlank = true; this.RightFlank = true; this.RallyPoint = rallyPoint; this.AverageTrackerX = new AverageTracker(); this.AverageTrackerY = new AverageTracker(); this.StandingOrder = standingOrder; this.UnitFormation = unitFormation; this.UnitFacing = unitFacing; this.EntityIdInForPositionZero = null; this.OriginalUnitStrength = 0; this._BattleReadyEntityIds = new List <string>(); this._RoutedEntityIds = new List <string>(); this._DeadEntityIds = new List <string>(); }
public FleetState(FleetState orig) { Formation = orig.Formation; SearchResult = orig.SearchResult; Ships = new ShipState[] { new ShipState(orig.Ships[0]),new ShipState(orig.Ships[1]), new ShipState(orig.Ships[2]),new ShipState(orig.Ships[3]), new ShipState(orig.Ships[4]),new ShipState(orig.Ships[5]) }; }
private int GetRoleCountByFormationType(FormationType type) { switch (type) { case FormationType.Type1: return 3; default: return 0; } }
//根据阵型摆放角色 private void SetRoleItemPos(FormationType type, RoleType roletype) { switch (type) { case FormationType.Type1: if (roletype == RoleType.Hero) { Vector3 startPos = new Vector3(-140, -700, 0); float offset = 140; int n = 0; for (int i = 0; i < RoleItems.Count; i++) { if (RoleItems[i].GetComponent<BattleRoleItem>().GetMyRoleData().roleType == roletype) { RoleItems[i].transform.localPosition = new Vector3(startPos.x + offset * n++, startPos.y, 0); } } } else if (roletype == RoleType.Npc) { Vector3 startPos = new Vector3(-140, -380, 0); float offset = 140; int n = 0; for (int i = 0; i < RoleItems.Count; i++) { if (RoleItems[i].GetComponent<BattleRoleItem>().GetMyRoleData().roleType == roletype) { RoleItems[i].transform.localPosition = new Vector3(startPos.x + offset * n++, startPos.y, 0); } } } break; default: break; } }
public Wave(FormationType ft, EntryBehavior nb, LoiterBehavior lb, AttackType at, ExitTrigger xt, ExitBehavior xb, float timeTillNextWave, bool boundsCheck) { this.ft = ft; this.nb = nb; this.lb = lb; this.at = at; this.xt = xt; this.xb = xb; this.waveDuration = timeTillNextWave; this.boundsCheck = boundsCheck; }
private void CreateFormat(BlockTypes type, int x, int y, int z, FormationType format) { switch (format) { case FormationType.ThreeDCross: //3D Cross SetBlocktype(x, y, z, (byte)type); SetBlocktype(x - 1, y, z, (byte)type); SetBlocktype(x + 1, y, z, (byte)type); SetBlocktype(x, y, z + 1, (byte)type); SetBlocktype(x, y, z - 1, (byte)type); SetBlocktype(x, y - 1, z, (byte)type); SetBlocktype(x, y + 1, z, (byte)type); break; case FormationType.BigL: //Kind of laying big "L" SetBlocktype(x, y, z, (byte)type); SetBlocktype(x + 1, y + 1, z, (byte)type); SetBlocktype(x - 1, y, z, (byte)type); SetBlocktype(x + 1, y, z, (byte)type); break; case FormationType.Cube: //Cube SetBlocktype(x, y + 1, z, (byte)type); SetBlocktype(x, y - 1, z, (byte)type); SetBlocktype(x, y - 1, z - 1, (byte)type); SetBlocktype(x, y + 1, z - 1, (byte)type); break; case FormationType.SmallL: //Kind of staying small "L" SetBlocktype(x, y + 2, z, (byte)type); SetBlocktype(x, y + 1, z, (byte)type); SetBlocktype(x, y, z - 1, (byte)type); break; } }
// Use this for initialization void Start() { targetPosition = transform.position; _formationMode = false; _formationType = FormationType.Delta; }
public DroneArmyTrap(float offset, Transform droneSoldierPrefab, FormationType formationType) : base(offset) { this.drones = new List<Transform>(); this.formationType = formationType; foreach (var position in this.GetPositions(offset, formationType)) { var drone = Instantiate(droneSoldierPrefab).transform; drone.position = position; drone.forward = new Vector3(-1, 0, 0); drone.Rotate(new Vector3(20, 0, 0), Space.Self); drone.GetComponent<Collider>().isTrigger = true; drone.parent = this.gameObject.transform; this.drones.Add(drone); } }
private IEnumerable<Vector3> GetPositions(float offset, FormationType formationType) { switch (formationType) { case FormationType.DeathJaws: return Enumerable.Repeat(new Vector3(offset, 0, 0), 9); default: return Enumerable.Empty<Vector3>(); } }
public Wave(FormationType ft) { this.ft = ft; }