public override void process(Ocean ocean) { Coordinate toCoord; toCoord = LogicMove.getPreyNeighborCoord(ocean, offset); if (toCoord._x == offset._x && toCoord._y == offset._y) { --_timeToReproduce; toCoord = LogicMove.getEmptyNeighborCoord(ocean, offset); _swim.moveFrom(offset, toCoord, ocean, this); } else { if (_timeToReproduce == 0) { _timeToReproduce = TIME_TO_REPRODUCE; Coordinate tmpMove = LogicMove.getEmptyNeighborCoord(ocean, offset); ocean.assignCellAt(tmpMove, (Prey)_swim.reproduce(tmpMove, ocean)); ++ocean.NumPrey; ++ocean.NumReproduce; } else { toCoord = LogicMove.getEmptyNeighborCoord(ocean, offset); _swim.moveFrom(offset, toCoord, ocean, this); } } }
public override bool TickMove(LogicMove lm, int ms) { int useDelta = this._lifeRemain < ms ? this._lifeRemain : ms; lm.MoveOneStep(useDelta * speed * 0.001f * this._dir); this._lifeRemain -= useDelta; return(this._lifeRemain == 0); }
public void addPrey(ISwim prey) { Coordinate empty; for (int i = 0; i < NumPrey; i++) { empty = LogicMove.getEmptyCellCoord(this); cells[empty._y, empty._x] = new Prey(empty, prey, Prey.TIME_TO_REPRODUCE); } }
public void addPredators(ISwim pred) { Coordinate empty; for (int i = 0; i < NumPredator; i++) { empty = LogicMove.getEmptyCellCoord(this); cells[empty._y, empty._x] = new Predator(empty, pred); } }
public void addObstacles() { Coordinate empty; for (int i = 0; i < NumObstacles; i++) { empty = LogicMove.getEmptyCellCoord(this); cells[empty._y, empty._x] = new Obstacles(empty); } }
public LogicEntity CreateBullet(LogicEntity releaserEntity) { AttrComponent attr = releaserEntity.GetComponent <AttrComponent>(); LogicEntity result = CreateEntityByResPath(""); result.SetLifeTime(attr.GetAttr(Attr.BulletLife)); result.AddComponent <BulletComponent>(releaserEntity); LogicMove moveComp = result.AddComponent <LogicMove>(); moveComp.AddMove(releaserEntity.LogicTran.forward, attr.GetAttr(Attr.BulletSpeed), attr.GetAttr(Attr.BulletLife), null); return(result); }
public override bool LogicTick(StateMachine machine, int ms) { if (!_isAvaliable) { return(true); } _isAvaliable = false; LogicMove lm = machine.HostEntity.GetComponent <LogicMove>(); if (lm != null) { AttrComponent attr = machine.HostEntity.GetComponent <AttrComponent>(); SafeFloat speed = attr.GetAttr(Attr.MoveSpeed); lm.MoveOneStep(speed * new SafeV3(_args.DirX, 0, _args.DirZ)); } return(false); }
public override void process(Ocean ocean) { Coordinate toCoord; if (--_timeToFeed >= 0) { toCoord = LogicMove.getPreyNeighborCoord(ocean, offset); if (toCoord._x == offset._x && toCoord._y == offset._y) { toCoord = LogicMove.getEmptyNeighborCoord(ocean, offset); _swim.moveFrom(offset, toCoord, ocean, this); } else { _timeToFeed = TIME_TO_FEED; --ocean.NumPrey; ++ocean.NumKill; _swim.moveFrom(offset, toCoord, ocean, this); } } }
public override bool TickMove(LogicMove lm, int ms) { LogicEntity targetEntity = EntityManager.Instance.GetEntity(this._targetId); if (targetEntity == null) { this.InvokeCallback(true); return(true); } LogicTransform targetTran = targetEntity.GetComponent <LogicTransform>(); SafeV3 dir = targetTran.position - lm.HostEntity.LogicTran.position; if (dir.magnitude * 1000 < speed * ms) { lm.HostEntity.LogicTran.position = targetTran.position; this.InvokeCallback(false); return(true); } dir.SetNormalize(); lm.MoveOneStep(ms * speed * 0.001f * dir); return(false); }
public abstract bool TickMove(LogicMove lm, int ms);