예제 #1
0
        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);
                }
            }
        }
예제 #2
0
        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);
        }
예제 #3
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);
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        public void addObstacles()
        {
            Coordinate empty;

            for (int i = 0; i < NumObstacles; i++)
            {
                empty = LogicMove.getEmptyCellCoord(this);
                cells[empty._y, empty._x] = new Obstacles(empty);
            }
        }
예제 #6
0
    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);
    }
예제 #7
0
    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);
    }
예제 #8
0
        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);
                }
            }
        }
예제 #9
0
        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);
        }
예제 #10
0
 public abstract bool TickMove(LogicMove lm, int ms);