private void UpdateInit(IUpdateEventArgs args) { _targetting = new RadiusExitTargetting(args.Sim.Map, _host.Tile, 1, 1); _targetting.OwnTeam = _host.Stats.Team; _state = TowerBehaviourState.Searching; }
private float UpdateAdvancing(IUpdateEventArgs args) { // advance through tile _agent.TileProgress += _agent.Stats.MovementSpeed * args.Ticks; // advance to next tile, if necessary while (_agent.TileProgress > 1 && _pathIndex < (_mapPath.Count - 1)) { // move to next tile _pathIndex += 1; _agent.TileProgress -= 1.0f; args.Manager.Move(_agent, _mapPath[_pathIndex]); } // are we done? if (_pathIndex == (_mapPath.Count - 1) && _agent.TileProgress >= 0.5f) { _state = PathMobBehaviourStates.EndOfPath; } // calculate Position UpdatePosition(); return(1.0f); }
private float UpdateInit(IUpdateEventArgs args) { // move into initial tile _pathIndex = 0; args.Manager.Move(_agent, _mapPath[_pathIndex]); _agent.TileProgress = 0.5f; // start in the center of our source tile _state = PathMobBehaviourStates.Advancing; return(1.0f); }
public float Update(IUpdateEventArgs args) { _elapsedTicks += args.Ticks; // reschedule if schedule not elapsed if (_elapsedTicks < _offsetTicks) { return(_offsetTicks - _elapsedTicks); } OnElapsed(args); return(0.0f); }
public float Update(IUpdateEventArgs args) { // Update according to the current state of the agent switch (_state) { case TowerBehaviourState.Init: UpdateInit(args); break; case TowerBehaviourState.Searching: UpdateSearching(); break; case TowerBehaviourState.Aiming: UpdateAiming(args.Ticks); break; case TowerBehaviourState.Attacking: UpdateAttacking(); break; case TowerBehaviourState.Removed: return(0.0f); default: throw new ArgumentOutOfRangeException(); } // Reschedule according to the (potentially updated) state of the agent switch (_state) { case TowerBehaviourState.Init: return(_ticksPerSecond / InitResolution); case TowerBehaviourState.Searching: return(_ticksPerSecond / SearchResolution); case TowerBehaviourState.Aiming: return(_ticksPerSecond / AimingResolution); case TowerBehaviourState.Attacking: return(_ticksPerSecond / AttackResolution); case TowerBehaviourState.Removed: return(0.0f); default: throw new ArgumentOutOfRangeException(); } }
public float Update(IUpdateEventArgs args) { switch (_state) { case PathMobBehaviourStates.Init: return(UpdateInit(args)); case PathMobBehaviourStates.Advancing: return(UpdateAdvancing(args)); case PathMobBehaviourStates.EndOfPath: return(UpdateEndOfPath(args)); case PathMobBehaviourStates.Removed: // do nothing return(0.0f); default: throw new ArgumentOutOfRangeException(); } }
public float Update(IUpdateEventArgs args) { return(BehaviourComponent.Update(args)); }
protected abstract void OnElapsed(IUpdateEventArgs args);
public float Update(IUpdateEventArgs args) { // indicate that we do not require any further updates return(0.0f); }
protected override void OnElapsed(IUpdateEventArgs args) { var agent = args.Manager.CreateAgent(_agentName, _createArgs); args.Manager.Register(agent); }
public float Update(IUpdateEventArgs args) { OnElapsed(args); return(0.0f); }
private float UpdateEndOfPath(IUpdateEventArgs args) { args.Manager.Remove(this._agent); return(0.0f); }