public static LSAgent GetScreenAgent(Vector2 screenPos, Func<LSAgent, bool> conditional = null) { if (conditional == null) conditional = (agent) => { return true;}; agentFound = false; Ray ray = Camera.main.ScreenPointToRay (screenPos); checkDir = ray.direction; checkOrigin = ray.origin; for (int i = 0; i < AgentController.PeakGlobalID; i++) { if (AgentController.GlobalAgentActive [i]) { LSAgent agent = AgentController.GlobalAgents [i]; if (agent.IsVisible) { if (conditional (agent)) { if (AgentIntersects (agent)) { if (agentFound) { if (heightDif < closestDistance) { closestDistance = heightDif; closestAgent = agent; } } else { agentFound = true; closestAgent = agent; closestDistance = heightDif; } } } } } } if (agentFound) return closestAgent; return null; }
public void ScanAll(int deltaCount, FastList<LSAgent> outputAgents, bool CheckAllegiance = false, AllegianceType allegianceType = AllegianceType.Neutral) { for (i = 0; i < deltaCount; i++) { tempNode = GridManager.GetNode ( LocatedNode.gridX + DeltaCache.CacheX[i], LocatedNode.gridY + DeltaCache.CacheY[i]); if (tempNode != null && tempNode.LocatedAgents != null) { tempBucket = tempNode.LocatedAgents; for (j = 0; j < tempBucket.PeakCount; j++) { if (LSUtility.GetBitTrue (tempBucket.arrayAllocation, j)) { tempAgent = tempBucket.innerArray [j].Agent; if (System.Object.ReferenceEquals (tempAgent, Agent) == false) { if (CheckAllegiance) { if (Agent.MyAgentController.DiplomacyFlags [tempAgent.MyAgentController.ControllerID] != allegianceType) continue; } outputAgents.Add (tempAgent); } } } } } }
public void Initialize(LSAgent agent) { Agent = agent; Body = agent.Body; LocatedNode = GridManager.GetNode (Body.Position.x, Body.Position.y); LocatedNode.Add (this); }
public override void Initialize(LSAgent agent) { Body = agent.Body; timescaledTurnRate = TurnRate * LockstepManager.Timestep >> FixedMath.SHIFT_AMOUNT; TargetReached = true; TargetRotation = Vector2d.up; }
public static void BoxAgent(LSAgent agent) { if (System.Object.ReferenceEquals (agent, null)) return; BoxedAgents.Add (agent); agent.IsHighlighted = true; }
public static void BoxAgent(LSAgent agent) { if (agent == null) return; BoxedAgents.Add (agent); agent.IsHighlighted = true; }
void Start() { LockstepManager.Initialize (); GridManager.Generate (); const int count = 32; for (int i = -count; i < count; i++) { for (int j = -count; j < count; j++) { if (i * i + j * j < 16) continue; if (LSUtility.GetRandom (2) == 0) { Vector2d pos = new Vector2d(i,j); GridManager.GetNode(pos.x,pos.y).Unwalkable = true; Instantiate(TestWall).GetComponent<LSBody>().Initialize(pos); } } } /*LSBody wall = Instantiate (TestWall).GetComponent<LSBody> (); wall.Initialize (new Vector2d (-32 + 14, 0)); for (long i = wall.XMin; i <= wall.XMax; i+= FixedMath.One) { for (long j = wall.YMin; j <= wall.YMax; j+= FixedMath.One) { GridManager.GetNode (i, j).Unwalkable = true; } }*/ GridManager.Initialize (); controller = AgentController.Create (); for (int i = 0; i < 256; i++) { agent = controller.CreateAgent (AgentCode.Minion); } PlayerManager.AddAgentController (controller); }
public static void Remove (LSAgent agent) { leIndex = agent.BoxedAgentsIndex; agent.BoxedAgentsIndex = -1; OpenSlots.Add (leIndex); arrayAllocated[leIndex] = false; Count--; }
public void Setup(LSAgent agent) { cachedRenderer = GetComponent<Renderer>(); cachedMaterial = cachedRenderer.material; transform.parent = agent.VisualCenter; transform.localPosition = Vector3.zero; float size = agent.SelectionRadius * 2; transform.localScale = new Vector3(size,size,1); }
public override void Initialize(LSAgent agent) { MyMovementGroupID = -1; Body = agent.Body; Body.Mover = this; Body.OnContact += HandleCollision; timescaledSpeed = ((Speed * LockstepManager.Timestep) >> FixedMath.SHIFT_AMOUNT); closingDistance = agent.Body.Radius; }
public void Initialize(LSAgent agent) { if (this.renderer == null) this.renderer = base.GetComponent<Renderer>(); material = this.renderer.material; if (this.transform == null) this.transform = base.GetComponent<Transform> (); float scale = agent.SelectionRadius * 2; transform.localScale = new Vector3(scale,scale,scale); material.color = UnselectColor; Agent = agent; }
public static void Add (LSAgent agent) { if (OpenSlots.Count > 0) { leIndex = OpenSlots.Pop (); } else { leIndex = PeakCount++; } agent.BoxedAgentsIndex = leIndex; innerArray[leIndex] = agent; arrayAllocated[leIndex] = true; Count++; }
public static LSProjectile Create(string projCode, LSAgent source, LSAgent target, long damage) { FastStack<LSProjectile> pool = ProjectilePool[projCode]; if (pool.Count > 0) { curProj = pool.Pop (); } else { curProj = NewProjectile (projCode); } int id = GenerateID (); ProjectileBucket[id] = curProj; ProjectileActive[id] = true; curProj.Initialize (id, source,target); curProj.Damage = damage; return curProj; }
public static LSProjectile Create(ProjectileCode projCode, LSAgent source, LSAgent target, long damage) { if (Enum.IsDefined(typeof (ProjectileCode), projCode) == false) { throw new System.MissingMemberException("The specified ProjectileCode does not exist"); } FastStack<LSProjectile> pool = ProjectilePool[projCode]; if (pool.Count > 0) { curProj = pool.Pop (); } else { curProj = NewProjectile (projCode); } int id = GenerateID (); ProjectileBucket[id] = curProj; ProjectileActive[id] = true; curProj.Initialize (id, source,target); curProj.Damage = damage; return curProj; }
public static LSAgent Scan(int gridX, int gridY, int deltaCount, Func<LSAgent,bool> conditional, long sourceX, long sourceY) { agentFound = false; for (int i = 0; i < deltaCount; i++) { tempNode = GridManager.GetScanNode ( gridX + DeltaCache.CacheX [i], gridY + DeltaCache.CacheY [i]); if (tempNode .IsNotNull () && tempNode.LocatedAgents .IsNotNull ()) { tempBucket = tempNode.LocatedAgents; arrayAllocation = tempBucket.arrayAllocation; for (int j = 0; j < tempBucket.PeakCount; j++) { if (arrayAllocation.Get (j)) { tempAgent = tempBucket [j]; if (conditional (tempAgent)) { if (agentFound) { if ((tempDistance = tempAgent.Body.Position.FastDistance (sourceX, sourceY)) < closestDistance) { secondClosest = closestAgent; closestAgent = tempAgent; closestDistance = tempDistance; } } else { closestAgent = tempAgent; agentFound = true; closestDistance = tempAgent.Body.Position.FastDistance (sourceX, sourceY); } } } } if (agentFound) { return closestAgent; } } } return null; }
private static bool ScanConditionalSource(LSAgent agent) { if (System.Object.ReferenceEquals(agent, Source)) { return(false); } if (TargetAllegiance != AllegianceType.Any) { if (Source.GetAllegiance(agent) != TargetAllegiance) { return(false); } } if (TargetPlatform != PlatformType.Any) { if (agent.Platform != agent.Platform) { return(false); } } return(true); }
public void Engage(LSAgent other) { if (other != Agent && other != null) { cachedTargetHealth = other.GetAbility <Health>(); if (cachedTargetHealth.IsNotNull()) { OnEngage(other); Target = other; targetVersion = Target.SpawnVersion; IsCasting = true; fastRangeToTarget = Range + (Target.Body.IsNotNull() ? Target.Body.Radius : 0) + Agent.Body.Radius; fastRangeToTarget *= fastRangeToTarget; if (!CheckRange()) { if (CanMove) { cachedMove.StartMove(Target.Body.Position); } } } } }
public static LSProjectile Create(ProjectileCode projCode, LSAgent source, LSAgent target, long damage) { if (Enum.IsDefined(typeof(ProjectileCode), projCode) == false) { throw new System.MissingMemberException("The specified ProjectileCode does not exist"); } FastStack <LSProjectile> pool = ProjectilePool[projCode]; if (pool.Count > 0) { curProj = pool.Pop(); } else { curProj = NewProjectile(projCode); } int id = GenerateID(); ProjectileBucket[id] = curProj; ProjectileActive[id] = true; curProj.Initialize(id, source, target); curProj.Damage = damage; return(curProj); }
public static LSAgent FindClosestAgent(Vector2d position, IEnumerable <LSAgent> agents) { long sourceX = position.x; long sourceY = position.y; LSAgent closestAgent = null; long closestDistance = 0; int foundBuffer = FoundScanBuffer; foreach (LSAgent agent in agents) { if (FoundScanBuffer == 0) { break; } if (closestAgent != null) { long tempDistance = agent.Body._position.FastDistance(sourceX, sourceY); if (tempDistance < closestDistance) { closestAgent = agent; closestDistance = tempDistance; foundBuffer = FoundScanBuffer; } else { foundBuffer--; } } else { closestAgent = agent; closestDistance = agent.Body._position.FastDistance(sourceX, sourceY); } } return(closestAgent); }
private static void DestroyAgentBuffer(DeactivationData data) { LSAgent agent = data.Agent; if (agent.IsActive == false) { return; } bool immediate = data.Immediate; agent.Deactivate(immediate); ChangeController(agent, null); //Pool if the agent is registered ushort agentCodeID; if (agent.TypeIndex != UNREGISTERED_TYPE_INDEX) { if (CodeIndexMap.TryGetValue(agent.MyAgentCode, out agentCodeID)) { TypeAgentsActive[agentCodeID][agent.TypeIndex] = false; } } }
public static void ChangeController(LSAgent agent, AgentController newCont) { AgentController leController = agent.Controller; if (leController != null) { leController.LocalAgentActive[agent.LocalID] = false; GlobalAgentActive[agent.GlobalID] = false; leController.OpenLocalIDs.Add(agent.LocalID); OpenGlobalIDs.Add(agent.GlobalID); if (newCont == null) { agent.InitializeController(null, 0, 0); } else { agent.Influencer.Deactivate(); newCont.AddAgent(agent); agent.Influencer.Initialize(); } } }
public static int GetStateHash() { int operationToggle = 0; int hash = LSUtility.PeekRandom(int.MaxValue); for (int i = 0; i < PeakGlobalID; i++) { if (GlobalAgentActive[i]) { LSAgent agent = GlobalAgents[i]; int n1 = agent.Body._position.GetHashCode() + agent.Body._rotation.GetStateHash(); switch (operationToggle) { case 0: hash ^= n1; break; case 1: hash += n1; break; default: hash ^= n1 * 3; break; } operationToggle++; if (operationToggle >= 2) { operationToggle = 0; } } } return(hash); }
public static void Update() { MousePosition = Input.mousePosition; MouseWorldPosition = Interfacing.GetWorldPos (MousePosition); CanClearSelection = !Input.GetKey (KeyCode.LeftShift); GetMousedAgent (); if (Boxing) { BoxingTime += Time.deltaTime; if (MousePosition != BoxEnd) { Vector2 RaycastTopLeft; Vector2 RaycastTopRight; Vector2 RaycastBotLeft; Vector2 RaycastBotRight; BoxEnd = MousePosition; if (BoxStart.x < BoxEnd.x) { RaycastTopLeft.x = BoxStart.x; RaycastBotLeft.x = BoxStart.x; RaycastTopRight.x = BoxEnd.x; RaycastBotRight.x = BoxEnd.x; } else { RaycastTopLeft.x = BoxEnd.x; RaycastBotLeft.x = BoxEnd.x; RaycastTopRight.x = BoxStart.x; RaycastBotRight.x = BoxStart.x; } if (BoxStart.y < BoxEnd.y) { RaycastBotLeft.y = BoxStart.y; RaycastBotRight.y = BoxStart.y; RaycastTopLeft.y = BoxEnd.y; RaycastTopRight.y = BoxEnd.y; } else { RaycastBotLeft.y = BoxEnd.y; RaycastBotRight.y = BoxEnd.y; RaycastTopLeft.y = BoxStart.y; RaycastTopRight.y = BoxStart.y; } Box_TopLeft = Interfacing.GetWorldPos (RaycastTopLeft); Box_TopRight = Interfacing.GetWorldPos (RaycastTopRight); Box_BottomLeft = Interfacing.GetWorldPos (RaycastBotLeft); Box_BottomRight = Interfacing.GetWorldPos (RaycastBotRight); } ClearBox (); int lecount = 0; if ((BoxEnd - BoxStart).sqrMagnitude >= MinBoxSqrDist) { bufferBoxedAgents.Clear (); for (int i = 0; i < PlayerManager.AgentControllerCount; i++) { var agentController = PlayerManager.GetAgentController (i); for (int j = 0; j < AgentController.MaxAgents; j++) { if (agentController.LocalAgentActive [j]) { curAgent = agentController.LocalAgents [j]; if (curAgent.CanSelect) { if (curAgent.RefEquals (MousedAgent)) { bufferBoxedAgents.Add (curAgent); } else { agentPos = curAgent.Position2; Edge = Box_TopRight - Box_TopLeft; Point = agentPos - Box_TopLeft; if (DotEdge () < 0) { Edge = Box_BottomRight - Box_TopRight; Point = agentPos - Box_TopRight; if (DotEdge () < 0) { Edge = Box_BottomLeft - Box_BottomRight; Point = agentPos - Box_BottomRight; if (DotEdge () < 0) { Edge = Box_TopLeft - Box_BottomLeft; Point = agentPos - Box_BottomLeft; if (DotEdge () < 0) { bufferBoxedAgents.Add (curAgent); continue; } } } } } } } } } bufferBoxable.FastClear (); bool noneBoxable = true; if (bufferBoxedAgents.Count > 0) { int peakBoxPriority = bufferBoxedAgents.PeekMax ().BoxPriority; while (bufferBoxedAgents.Count > 0) { LSAgent agent = bufferBoxedAgents.PopMax (); if (agent.BoxPriority < peakBoxPriority) break; BoxAgent (agent); } } } else { BoxAgent (MousedAgent); } if (Input.GetMouseButtonUp (0)) { if (CanClearSelection) { ClearSelection (); } if (PlayerManager.IsInterfacing == false) { SelectBoxedAgents (); } Boxing = false; } } else { if (PlayerManager.IsInterfacing == false && InputManager.GetInformationDown ()) { CheckBoxDistance = true; Boxing = true; BoxingTime = 0f; BoxStart = MousePosition; BoxEnd = MousePosition; } } }
public static void SelectAgent(LSAgent agent) { if (agent .IsNotNull ()) { agent.IsSelected = true; Selector.Add (agent); } }
public void InitializeTimed(LSAgent target) { this.Target = target; this.TargetVersion = this.Target.SpawnVersion; }
public static AllegianceType GetAllegiance(LSAgent agent) { return(PlayerManager.GetAllegiance(agent.Controller)); }
public void AddToSelection(LSAgent agent) { SelectedAgents.Add(agent); SelectionChanged = true; }
private void HandleCollision(LSBody other) { if (!CanMove) { return; } if ((tempAgent = other.Agent) == null) { return; } Move otherMover = tempAgent.GetAbility <Move>(); if (ReferenceEquals(otherMover, null) == false) { if (IsMoving) { //If the other mover is moving to a similar point if (otherMover.MyMovementGroupID == MyMovementGroupID || otherMover.targetPos.FastDistance(this.targetPos) <= (closingDistance * closingDistance)) { if (otherMover.IsMoving == false) { if (otherMover.Arrived && otherMover.StoppedTime > MinimumOtherStopTime) { Arrive(); } } else { if (hasPath && otherMover.hasPath && otherMover.pathIndex > 0 && otherMover.lastTargetPos.SqrDistance(targetPos.x, targetPos.y) < closingDistance.Mul(closingDistance)) { if (this.distance < this.closingDistance) { this.pathIndex++; } } } } if (GetLookingForStopPause()) { //As soon as the original collision stop unit is released, units will start breaking out of pauses if (otherMover.GetCanCollisionStop() == false) { StopPauseLayer = -1; PauseAutoStop(); } else if (otherMover.GetCanAutoStop() == false) { if (otherMover.StopPauseLayer < StopPauseLayer) { StopPauseLayer = otherMover.StopPauseLayer + 1; PauseAutoStop(); } } } else { } } } }
public LSProjectile PrepareProjectile(string projectileCode, Vector3d projOffset, LSAgent target) { LSProjectile currentProjectile = ProjectileManager.Create( projectileCode, this.Agent, projOffset, this.TargetAllegiance, (other) => { Health healther = other.GetAbility <Health>(); return(healther.IsNotNull() && healther.HealthAmount > 0); }, CachedOnHit); switch (currentProjectile.TargetingBehavior) { case TargetingType.Homing: currentProjectile.InitializeHoming(target); break; case TargetingType.Timed: currentProjectile.InitializeTimed(Agent.Body.Forward); break; case TargetingType.Positional: currentProjectile.InitializePositional(target.Body.Position.ToVector3d(target.Body.HeightPos)); break; case TargetingType.Free: //TODO throw new System.Exception("Not implemented yet."); //break; } OnPrepareProjectile(currentProjectile); return(currentProjectile); }
public AllegianceType GetAllegiance(LSAgent other) { return(Controller.GetAllegiance(other.Controller)); }
protected virtual void OnApplyEffect(LSAgent agent) { }
protected virtual void ApplyEffect(LSAgent agent) { OnApplyEffect(agent); }
private void OnChildDie(LSAgent agent) { agent.onDeactivation -= OnChildDie; //Occupied = false; }
protected virtual bool AgentValid(LSAgent agent) { return(true); }
public static void Add(LSAgent agent) { innerArray[Count++] = agent; agent.BoxVersion = _Version; }
public bool AllButFriendly(LSAgent other) { return(this.Source.GetAllegiance(other) != AllegianceType.Friendly); }
public static void CacheAgent(LSAgent agent) { CachedAgents [agent.MyAgentCode].Add(agent); }
public void DestroyAgent(LSAgent agent) { agent.Deactivate (); CachedAgents[(int)agent.MyAgentCode].Add (agent); OpenLocalIDs.Add (agent.LocalID); AgentActive[agent.LocalID] = false; }
public void RemoveFromSelection(LSAgent agent) { SelectedAgents.Remove(agent); SelectionChanged = true; }
public void Setup(LSAgent agent) { Agent = agent; Body = agent.Body; }
public static void Update() { MousePosition = Input.mousePosition; MouseWorldPosition = RTSInterfacing.GetWorldPos(MousePosition); CanClearSelection = !Input.GetKey(KeyCode.LeftShift); GetMousedAgent(); if (Boxing) { if (CanBox) { BoxingTime += Time.deltaTime; if (MousePosition != BoxEnd) { Vector2 RaycastTopLeft; Vector2 RaycastTopRight; Vector2 RaycastBotLeft; Vector2 RaycastBotRight; BoxEnd = MousePosition; if (BoxStart.x < BoxEnd.x) { RaycastTopLeft.x = BoxStart.x; RaycastBotLeft.x = BoxStart.x; RaycastTopRight.x = BoxEnd.x; RaycastBotRight.x = BoxEnd.x; } else { RaycastTopLeft.x = BoxEnd.x; RaycastBotLeft.x = BoxEnd.x; RaycastTopRight.x = BoxStart.x; RaycastBotRight.x = BoxStart.x; } if (BoxStart.y < BoxEnd.y) { RaycastBotLeft.y = BoxStart.y; RaycastBotRight.y = BoxStart.y; RaycastTopLeft.y = BoxEnd.y; RaycastTopRight.y = BoxEnd.y; } else { RaycastBotLeft.y = BoxEnd.y; RaycastBotRight.y = BoxEnd.y; RaycastTopLeft.y = BoxStart.y; RaycastTopRight.y = BoxStart.y; } Box_TopLeft = RTSInterfacing.GetWorldPos(RaycastTopLeft); Box_TopRight = RTSInterfacing.GetWorldPos(RaycastTopRight); Box_BottomLeft = RTSInterfacing.GetWorldPos(RaycastBotLeft); Box_BottomRight = RTSInterfacing.GetWorldPos(RaycastBotRight); } ClearBox(); //int lecount = 0; if ((BoxEnd - BoxStart).sqrMagnitude >= MinBoxSqrDist) { bufferBoxedAgents.Clear(); for (int i = 0; i < PlayerManager.AgentControllerCount; i++) { var agentController = PlayerManager.GetAgentController(i); for (int j = 0; j < AgentController.MaxAgents; j++) { if (agentController.LocalAgentActive[j]) { curAgent = agentController.LocalAgents[j]; if (curAgent.CanSelect) { if (curAgent.RefEquals(MousedAgent)) { bufferBoxedAgents.Add(curAgent); } else { agentPos = curAgent.Position2; Edge = Box_TopRight - Box_TopLeft; Point = agentPos - Box_TopLeft; if (DotEdge() < 0) { Edge = Box_BottomRight - Box_TopRight; Point = agentPos - Box_TopRight; if (DotEdge() < 0) { Edge = Box_BottomLeft - Box_BottomRight; Point = agentPos - Box_BottomRight; if (DotEdge() < 0) { Edge = Box_TopLeft - Box_BottomLeft; Point = agentPos - Box_BottomLeft; if (DotEdge() < 0) { bufferBoxedAgents.Add(curAgent); continue; } } } } } } } } } bufferBoxable.FastClear(); //bool noneBoxable = true; if (bufferBoxedAgents.Count > 0) { int peakBoxPriority = bufferBoxedAgents.PeekMax().BoxPriority; while (bufferBoxedAgents.Count > 0) { LSAgent agent = bufferBoxedAgents.PopMax(); if (agent.BoxPriority < peakBoxPriority) { break; } BoxAgent(agent); } } } else { BoxAgent(MousedAgent); } } if (Input.GetMouseButtonUp(0)) { if (CanClearSelection) { ClearSelection(); } if (IsGathering == false) { SelectBoxedAgents(); } Boxing = false; } } else { if (IsGathering == false && Input.GetMouseButtonDown(0)) { _checkBoxDistance = true; StartBoxing(MousePosition); } } }
private static void GetMousedAgent() { for (i = 0; i < AgentController.InstanceManagers.Count; i++) { AgentController agentController = AgentController.InstanceManagers [i]; for (j = 0; j < AgentController.MaxAgents; j++) { if (agentController.AgentActive [j]) { curAgent = agentController.Agents [j]; if (curAgent.cachedRenderer.isVisible) { dif = new Vector2 ( curAgent.transform.position.x - MouseWorldPosition.x, curAgent.transform.position.z - MouseWorldPosition.y); if ((dif.x * dif.x + dif.y * dif.y) <= (curAgent.SelectionRadius * curAgent.SelectionRadius)) { MouseOver (curAgent); return; } } } } } if (System.Object.ReferenceEquals (MousedAgent, null)==false) { MousedAgent.IsHighlighted = false; MousedAgent = null; } }
public override void Initialize(LSAgent agent) { MyMovementGroupID = -1; Body = agent.Body; Body.Mover = this; Body.OnContact += HandleCollision; Turner = agent.GetAbility<Turn> (); timescaledSpeed = ((Speed * LockstepManager.Timestep) >> FixedMath.SHIFT_AMOUNT); closingDistance = agent.Body.Radius; RepathCount = LSUtility.GetRandom (RepathRate); ViableDestination = false; }
private static void MouseOver(LSAgent agent) { if (System.Object.ReferenceEquals (MousedAgent,agent)) { return; } if (System.Object.ReferenceEquals (MousedAgent, null)==false) { MousedAgent.IsHighlighted = false; } MousedAgent = agent; agent.IsHighlighted = true; }
public static void UnselectAgent(LSAgent agent) { if (agent .IsNotNull ()) { agent.IsSelected = false; Selector.Remove (agent); } }
public DeactivationData(LSAgent agent, bool immediate) { Agent = agent; Immediate = immediate; }
private static void MouseOver(LSAgent agent) { if (MousedAgent.RefEquals (agent)) { return; } if (MousedAgent .IsNotNull ()) { MousedAgent.IsHighlighted = false; } MousedAgent = agent; if (agent .IsNotNull ()) { if (SelectionManager.Boxing == false) agent.IsHighlighted = true; } }
public static void DestroyAgent(LSAgent agent, bool immediate = false) { DeactivationBuffer.Add(new DeactivationData(agent, immediate)); }
public override void Initialize(LSAgent agent) { }
protected virtual void OnApplyEffect(LSAgent agent, bool isCurrent) { }
public LSProjectile FullFireProjectile(string projectileCode, Vector3d projOffset, LSAgent target) { LSProjectile proj = (PrepareProjectile(projectileCode, projOffset, target)); FireProjectile(proj); return(proj); }
public int Add(LSAgent influencer) { //Weight += weightPerUnit; return LinkedScanNode.LocatedAgents.Add(influencer); }
protected virtual void OnEngage(LSAgent target) { }
public AttackerInfo(LSAgent attacker, AgentController controller) { Attacker = attacker; Controller = controller; }
public abstract void Initialize (LSAgent agent);
public static void SelectAgent(LSAgent agent) { if (agent == null) return; SelectedAgents.Add (agent); agent.IsSelected = true; }
private void DealDamage(LSAgent agent) { agent.Healther.TakeProjectile(this); }
public static void UnselectAgent(LSAgent agent) { if (agent == null) return; SelectedAgents.Remove (agent); agent.IsSelected = false; }
public LSAgent CreateAgent(AgentCode agentCode) { FastStack<LSAgent> cache = CachedAgents[(int)agentCode]; if (cache != null && cache.Count > 0) { curAgent = cache.Pop (); } else { curAgent = GameObject.Instantiate (AgentObjects[(int)agentCode]).GetComponent<LSAgent> (); } localID = GenerateLocalID (); curAgent.LocalID = localID; Agents[localID] = curAgent; AgentActive[localID] = true; globalID = GenerateGlobalID (); curAgent.GlobalID = globalID; curAgent.Initialize (); RingController ringController = GameObject.Instantiate (LockstepManager.Instance.SelectionRing).GetComponent<RingController> (); ringController.Initialize (curAgent); curAgent.ringController = ringController; return curAgent; }
public static void Update() { MousePosition = Input.mousePosition; MouseWorldPosition = GetWorldPos (MousePosition); CanClearSelection = !Input.GetKey (KeyCode.LeftShift); GetMousedAgent (); if (Boxing) { BoxingTime += Time.deltaTime; if (MousePosition != BoxEnd) { Vector2 RaycastTopLeft; Vector2 RaycastTopRight; Vector2 RaycastBotLeft; Vector2 RaycastBotRight; BoxEnd = MousePosition; if (BoxStart.x < BoxEnd.x) { RaycastTopLeft.x = BoxStart.x; RaycastBotLeft.x = BoxStart.x; RaycastTopRight.x = BoxEnd.x; RaycastBotRight.x = BoxEnd.x; } else { RaycastTopLeft.x = BoxEnd.x; RaycastBotLeft.x = BoxEnd.x; RaycastTopRight.x = BoxStart.x; RaycastBotRight.x = BoxStart.x; } if (BoxStart.y < BoxEnd.y) { RaycastBotLeft.y = BoxStart.y; RaycastBotRight.y = BoxStart.y; RaycastTopLeft.y = BoxEnd.y; RaycastTopRight.y = BoxEnd.y; } else { RaycastBotLeft.y = BoxEnd.y; RaycastBotRight.y = BoxEnd.y; RaycastTopLeft.y = BoxStart.y; RaycastTopRight.y = BoxStart.y; } Box_TopLeft = GetWorldPos (RaycastTopLeft); Box_TopRight = GetWorldPos (RaycastTopRight); Box_BottomLeft = GetWorldPos (RaycastBotLeft); Box_BottomRight = GetWorldPos (RaycastBotRight); } ClearBox (); int lecount = 0; if ((BoxEnd - BoxStart).sqrMagnitude >= MinBoxSqrDist) for (i = 0; i < PlayerManager.agentControllers.Count; i++) { AgentController agentController = PlayerManager.agentControllers [i]; for (j = 0; j < AgentController.MaxAgents; j++) { if (agentController.AgentActive [j]) { curAgent = agentController.Agents [j]; if (curAgent.cachedRenderer.isVisible) { Vector2 agentPos = new Vector2 (curAgent.transform.position.x, curAgent.transform.position.z); Edge = Box_TopRight - Box_TopLeft; Point = agentPos - Box_TopLeft; if (DotEdge () < 0) { Edge = Box_BottomRight - Box_TopRight; Point = agentPos - Box_TopRight; if (DotEdge () < 0) { Edge = Box_BottomLeft - Box_BottomRight; Point = agentPos - Box_BottomRight; if (DotEdge () < 0) { Edge = Box_TopLeft - Box_BottomLeft; Point = agentPos - Box_BottomLeft; if (DotEdge () < 0) { BoxAgent (curAgent); continue; } } } } } if (curAgent.BoxVersion == BoxedAgents._BufferVersion) { curAgent.IsHighlighted = false; } } } } if (Input.GetMouseButtonUp (0)) { if (CanClearSelection) { ClearSelection (); } SelectBoxedAgents (); SelectAgent (MousedAgent); Boxing = false; } } else { if (Input.GetMouseButtonDown (0)) { CheckBoxDistance = true; Boxing = true; BoxingTime = 0f; BoxStart = MousePosition; BoxEnd = MousePosition; } } }