public override object PerformFunction() { ADLBaseAgent agent = this.GetAgent(); float conditionY = (float)Math.Round(this.GetY(), 2); float prevY = (float)Math.Round(agent.prevPosition.y, 2); Vector2 currentPosition = agent.GetComponent <Rigidbody2D>().position; float currY = (float)Math.Round(currentPosition.y, 2); //Debug.Log("Curr Y: " + currY + " Prev Y: " + prevY + " Condition Y: " + conditionY); if ((prevY <= conditionY && currY >= conditionY) || (prevY >= conditionY && currY <= conditionY)) { agent.GetComponent <Rigidbody2D>().position = new Vector2(currentPosition.x, conditionY); return(true); } return(false); }
public override object PerformFunction() { ADLBaseAgent agent = this.GetAgent(); float conditionX = (float)Math.Round(this.GetX(), 2); float prevX = (float)Math.Round(agent.prevPosition.x, 2); Vector2 currentPosition = agent.GetComponent <Rigidbody2D>().position; float currX = (float)Math.Round(currentPosition.x, 2); if ((prevX <= conditionX && currX >= conditionX) || (prevX >= conditionX && currX <= conditionX)) { agent.GetComponent <Rigidbody2D>().position = new Vector2(conditionX, currentPosition.y); return(true); } return(false); }
public Entity(ADLBaseAgent agent) { this.x = agent.transform.localPosition.x; this.y = agent.transform.localPosition.y; if (agent is ADLEnvironment) { this.width = 0; this.height = 0; } else { this.width = agent.transform.localScale.x * agent.GetComponent <BoxCollider2D>().size.x; this.height = agent.transform.localScale.y * agent.GetComponent <BoxCollider2D>().size.y; } this.agentName = agent.agentName; this.lifePoint = agent.lifePoint; this.attack = agent.attack; this.isAttacker = agent.isAttacker; this.isDefender = agent.isDefender; this.isFlippable = agent.isFlippable; this.isFlipper = agent.isFlipper; this.isProjectile = agent.isProjectile; this.isInvulnerable = agent.isInvulnerable; this.isHittableByProjectile = agent.isHittableByProjectile; this.isHittableByEnvironment = agent.isHittableByEnvironment; this.group = agent.group.ToString(); this.horizonDirection = (int)agent.horizonDirection; this.verticalDirection = (int)agent.verticalDirection; if (agent is ADLAgent) { this.currentState = ((ADLAgent)agent).simulationState.currentState.name; } }
public override object PerformFunction() { ADLBaseAgent agent = this.GetAgent(); string propertyKey = agent.agentName + "Y"; float y; if (ADLAgent.currentUpdatingAgent.simulationState.singleQueryProperties[ADLAction.performingAction].ContainsKey(this)) { y = (float)ADLAgent.currentUpdatingAgent.simulationState.singleQueryProperties[ADLAction.performingAction][this]; } else { y = agent.GetComponent <Rigidbody2D>().position.y; ADLAgent.currentUpdatingAgent.simulationState.singleQueryProperties[ADLAction.performingAction].Add(this, y); } return(y); }
public override object PerformFunction() { ADLBaseAgent firstAgent = this.GetAgent(0); ADLBaseAgent secondAgent = this.GetAgent(1); try{ float distance; if (ADLAgent.currentUpdatingAgent.simulationState.singleQueryProperties[ADLAction.performingAction].ContainsKey(this)) { distance = (float)ADLAgent.currentUpdatingAgent.simulationState.singleQueryProperties[ADLAction.performingAction][this]; } else { distance = Math.Abs(firstAgent.GetComponent <Rigidbody2D>().transform.localPosition.x - secondAgent.GetComponent <Rigidbody2D>().transform.localPosition.x); ADLAgent.currentUpdatingAgent.simulationState.singleQueryProperties[ADLAction.performingAction].Add(this, distance); } return(distance); } catch (NullReferenceException e) { Debug.LogError(e.Message); return(0); } }
public override object PerformFunction() { ADLBaseAgent agent = this.GetAgent(); float x; if (ADLAgent.currentUpdatingAgent.simulationState.singleQueryProperties[ADLAction.performingAction].ContainsKey(this)) { x = (float)ADLAgent.currentUpdatingAgent.simulationState.singleQueryProperties[ADLAction.performingAction][this]; } else { try{ x = agent.GetComponent <Rigidbody2D>().position.x; } catch (Exception e) when(e is NullReferenceException || e is MissingReferenceException) { Debug.LogWarningFormat("Specified Agent Not Found - {0}", e.Message); x = 0; } ADLAgent.currentUpdatingAgent.simulationState.singleQueryProperties[ADLAction.performingAction].Add(this, x); } return(x); }