// // Приказы // private void Move(DTRMVector2 position) { activeOrder = CreepState.Move; targetPosition = position; legs.targetPosition = targetPosition; targetVictim = null; }
private void MoveAttack(DTRMVector2 position) { activeOrder = CreepState.MoveAttack; targetPosition = position; targetVictim = null; FindTargetOrCarryOn(); }
private void Hold() { activeOrder = CreepState.Hold; targetPosition = myPosition.position; targetVictim = null; TryFindTarget(); }
private void Patrol(DTRMVector2 position) { targetPosition = position; patrolPosition = myPosition.position; activeOrder = CreepState.Patrol; targetVictim = null; FindTargetOrCarryOn(); }
private void MoveTowards(DTRMVector2 targetMovePosition) { DTRMVector2 desiredVelocity = (targetMovePosition - myPosition.position).normalized; desiredVelocity *= speed; velocity = desiredVelocity; MoveAccordingToSpeed(); }
void OnMouseUpAsButton() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { DTRMVector2 targetPosition = new DTRMVector2(TerrainCoordinates.GlobalToTerrain(hit.point)); HeroOrderManager.singleton.MoveOrder(targetPosition); } }
void OnMouseUpAsButton() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit) ) { DTRMVector2 targetPosition = new DTRMVector2( TerrainCoordinates.GlobalToTerrain(hit.point) ); HeroOrderManager.singleton.MoveOrder(targetPosition); } }
// // Object overrides // public override bool Equals(object o) { if (o == null) { return(false); } DTRMVector2 dtrmVector2 = (DTRMVector2)o; if (dtrmVector2 == null) { return(false); } return(this == dtrmVector2); }
public static List <Visible> GetCell(DTRMVector2 position) { if (!init) { Init(); } int x = ((position.x / gridStep) + gridSize / 2).ToInt(); int y = ((position.y / gridStep) + gridSize / 2).ToInt(); if (x < 0 || x >= gridSize || y < 0 || y >= gridSize) { Debug.LogError("Coordinates beyond limits for vision grid: " + position.ToString()); return(null); } return(grid[x, y]); }
// // ILegsListener // public void OnTargetReach() { switch (activeOrder) { case CreepState.Idle: Debug.LogWarning("Unexpected target reach event for state Idle!"); break; case CreepState.Hold: // Вернулись на место, отдыхаем. break; case CreepState.Move: activeOrder = CreepState.Idle; break; case CreepState.MoveAttack: activeOrder = CreepState.Idle; break; case CreepState.Attack: Debug.LogWarning("Unexpected target reach event for state Attack!"); break; case CreepState.Patrol: DTRMVector2 exchangePosition = targetPosition; targetPosition = patrolPosition; patrolPosition = exchangePosition; legs.targetPosition = targetPosition; break; default: Debug.LogError("Unknown order!"); break; } }
public static List <Visible> GetNeighbors(DTRMVector2 position) { if (!init) { Init(); } int x = ((position.x / gridStep) + gridSize / 2).ToInt(); int y = ((position.y / gridStep) + gridSize / 2).ToInt(); if (x < 0 || x >= gridSize || y < 0 || y >= gridSize) { Debug.LogError("Coordinates beyond limits for vision grid: " + position.ToString()); return(null); } List <Visible> result = new List <Visible>(); // foreach(Visible v in grid[x][y]) // result.Add(v); for (int loopX = x - 1; loopX <= x + 1; loopX++) { for (int loopY = y - 1; loopY <= y + 1; loopY++) { if (loopX >= 0 && loopX < gridSize && loopY >= 0 && loopY < gridSize) { result.AddRange(grid[loopX, loopY]); } } } return(result); }
public HeroOrder(HeroController destination, DTRMVector2 targetPosition) : base(destination) { orderType = HeroOrderType.Move; this.targetPosition = targetPosition; }
public void GiveTarget(DTRMVector2 target) { activeState = PlayerState.Move; attack.DropTarget(); legs.targetPosition = target; }
public override void DTRMStart() { // TODO: change to a proper editor-based initialization! position = new DTRMVector2(transform.position.x, transform.position.z); }
private void Patrol(DTRMVector2 position) { targetPosition = position; patrolPosition = myPosition.position; activeOrder = CreepState.Patrol; targetVictim = null; FindTargetOrCarryOn(); }
private void MoveAttack(DTRMVector2 position) { activeOrder = CreepState.MoveAttack; targetPosition = position; targetVictim = null; FindTargetOrCarryOn(); }
public static List<Visible> GetCell(DTRMVector2 position) { if (!init) Init(); int x = ( ( position.x / gridStep ) + gridSize / 2 ).ToInt(); int y = ( ( position.y / gridStep ) + gridSize / 2 ).ToInt(); if ( x < 0 || x >= gridSize || y < 0 || y >= gridSize ) { Debug.LogError("Coordinates beyond limits for vision grid: " + position.ToString() ); return null; } return grid[x, y]; }
private void MoveTowards(DTRMVector2 targetMovePosition, FixedPoint speedPercentage) { DTRMVector2 desiredVelocity = (targetMovePosition - myPosition.position).normalized; desiredVelocity *= speed; desiredVelocity *= speedPercentage; velocity = desiredVelocity; MoveAccordingToSpeed(); }
public HeroOrder(HeroController destination, DTRMVector2 targetPosition) : base(destination) { orderType = HeroOrderType.Move; this.targetPosition = targetPosition; }
public void MoveOrder(DTRMVector2 targetPosition) { HeroController myHero = HeroManager.singleton.Hero (Network.player); networkView.RPC("ReceiveMoveOrder", RPCMode.All, destinationStep, targetPosition.ToVector3(), myHero.dtrmID); }
// // ILegsListener // public void OnTargetReach() { switch(activeOrder) { case CreepState.Idle: Debug.LogWarning("Unexpected target reach event for state Idle!"); break; case CreepState.Hold: // Вернулись на место, отдыхаем. break; case CreepState.Move: activeOrder = CreepState.Idle; break; case CreepState.MoveAttack: activeOrder = CreepState.Idle; break; case CreepState.Attack: Debug.LogWarning("Unexpected target reach event for state Attack!"); break; case CreepState.Patrol: DTRMVector2 exchangePosition = targetPosition; targetPosition = patrolPosition; patrolPosition = exchangePosition; legs.targetPosition = targetPosition; break; default: Debug.LogError("Unknown order!"); break; } }
public void MoveOrder(DTRMVector2 targetPosition) { HeroController myHero = HeroManager.singleton.Hero(Network.player); networkView.RPC("ReceiveMoveOrder", RPCMode.All, destinationStep, targetPosition.ToVector3(), myHero.dtrmID); }
private void Hold() { activeOrder = CreepState.Hold; targetPosition = myPosition.position; targetVictim = null; TryFindTarget(); }
public void GiveTarget(DTRMVector2 target) { activeState = PlayerState.Move; attack.DropTarget(); legs.targetPosition = target; }
// // Приказы // private void Move(DTRMVector2 position) { activeOrder = CreepState.Move; targetPosition = position; legs.targetPosition = targetPosition; targetVictim = null; }
public static List<Visible> GetNeighbors(DTRMVector2 position) { if (!init) Init(); int x = ( ( position.x / gridStep ) + gridSize / 2 ).ToInt(); int y = ( ( position.y / gridStep ) + gridSize / 2 ).ToInt(); if ( x < 0 || x >= gridSize || y < 0 || y >= gridSize ) { Debug.LogError("Coordinates beyond limits for vision grid: " + position.ToString() ); return null; } List<Visible> result = new List<Visible>(); // foreach(Visible v in grid[x][y]) // result.Add(v); for (int loopX = x-1; loopX <= x+1; loopX++) for (int loopY = y-1; loopY <= y+1; loopY++) if (loopX >= 0 && loopX < gridSize && loopY >= 0 && loopY < gridSize) result.AddRange(grid[loopX, loopY]); return result; }
public override void DTRMStart() { // TODO: change to a proper editor-based initialization! position = new DTRMVector2(transform.position.x, transform.position.z); }