コード例 #1
0
ファイル: Prey.cs プロジェクト: StasPeriphery/Game_Live
        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 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);
                }
            }
        }