コード例 #1
0
ファイル: SunkSubmarine.cs プロジェクト: temik911/audio
 public SunkSubmarine(Cell cell, Color color)
 {
     Texture = LogicService.sunk;
     this.color = color;
     this.Cell = cell;
     Order = 2;
 }
コード例 #2
0
ファイル: BaseC.cs プロジェクト: temik911/audio
 public BaseC(Cell cell, Team team)
 {
     Cell = cell;
     Parent = team;
     Texture = LogicService.baseC;
     Order = 1;
 }
コード例 #3
0
ファイル: Boom.cs プロジェクト: temik911/audio
 public Boom(Cell cell, GameTime gameTime, EntityCollection parent)
 {
     Texture = LogicService.boom;
     this.Cell = cell;
     startedTime = gameTime.Total.TotalSeconds;
     this.parent = parent;
     Order = 6;
 }
コード例 #4
0
ファイル: CustomMarker.cs プロジェクト: temik911/audio
 public static CustomMarker getMarker(String name, Cell cell)
 {
     Texture2D texture;
     if (textures.TryGetValue(name, out texture))
         return new CustomMarker(texture, cell);
     else
         return null;
 }
コード例 #5
0
ファイル: Mine.cs プロジェクト: temik911/audio
 internal Mine(Cell cell, Team team)
 {
     Texture = LogicService.mine;
     Parent = team;
     Cell = cell;
     _noise = Config.NOISE_BOOM_MINE;
     Order = 3;
 }
コード例 #6
0
ファイル: Move.cs プロジェクト: temik911/audio
 public Move(Entity sub, Cell to, ActionsQueue queue, float speed, double noise)
 {
     k++;
     Entity = sub;
     this.to = to;
     ActionsQueue = queue;
     Noise = noise;
     _speed = speed;
 }
コード例 #7
0
ファイル: Check.cs プロジェクト: temik911/audio
 public Check(Entity entity, ActionsQueue queue, Double noise, Cell to, Cell from, float speed)
 {
     this.noise = noise;
     this.queue = queue;
     this.entity = entity;
     this.to = to;
     this.from = from;
     this.speed = speed;
 }
コード例 #8
0
ファイル: AStar.cs プロジェクト: temik911/audio
 //float Critetion(Cell) {
 //    return 0.5;
 //}
 private float GetDistanceBetweenNeighbours(Cell from, Cell to, Func<Cell, Cell, float> weightFunc = null)
 {
     //FindPath(0, 0, 0, Critetion);
     //return ((from.Type == CellType.DEEP) && (from.Type == to.Type)) ? 1 : 9999;
     if (weightFunc == null)
     {
         return 1;
     }
     return weightFunc.Invoke(from, to);
 }
コード例 #9
0
ファイル: Submarine.cs プロジェクト: temik911/audio
 internal Submarine(Cell cell, Team team, Texture2D texture, int number, int health, int tCount, int mCount)
 {
     this.Cell = cell;
     this.X = cell.X - Config.OffsetX;
     this.Y = cell.Y - Config.OffsetY;
     this.Parent = team;
     this._healths = health;
     this.Texture = texture;
     this._health = LogicService.health;
     Order = 5;
     _number = number;
     _torpedoCount = tCount;
     _minesCount = mCount;
 }
コード例 #10
0
ファイル: Submarine.cs プロジェクト: temik911/audio
 public Submarine(Cell cell, Team team, Texture2D texture)
 {
     this.Cell = cell;
     this.X = cell.X - Config.OffsetX;
     this.Y = cell.Y - Config.OffsetY;
     this.Parent = team;
     this._healths = 3;
     this.Texture = texture;
     this._health = LogicService.health;
     Order = 5;
     _number = count;
     count++;
     _torpedoCount = Config.TORPEDO_COUNT;
     _minesCount = Config.MINES_COUNT;
 }
コード例 #11
0
ファイル: AStar.cs プロジェクト: temik911/audio
        private Collection<PathNode> GetNeighbours(PathNode pathNode, Cell goal, GameField field, Func<Cell, Cell, float> weightFunc = null)
        {
            var result = new Collection<PathNode>();

            List<Cell> neighboursCell = pathNode.Position.Neighbours;

            foreach (var point in neighboursCell)
            {
                if (point.Type == CellType.LAND)
                    continue;

                var neighbourNode = new PathNode()
                {
                    Position = point,
                    CameFrom = pathNode,
                    PathLengthFromStart = pathNode.PathLengthFromStart + GetDistanceBetweenNeighbours(pathNode.Position, point, weightFunc),
                    HeuristicEstimatePathLength = GetHeuristicPathLength(point, goal)
                };
                result.Add(neighbourNode);
            }
            return result;
        }
コード例 #12
0
ファイル: AStar.cs プロジェクト: temik911/audio
 public List<Cell> FindPath(GameField field, Cell start, Cell goal, Func<Cell, Cell, float> weightFunc = null)
 {
     var closedSet = new Collection<PathNode>();
     var openSet = new Collection<PathNode>();
     PathNode startNode = new PathNode()
     {
         Position = start,
         CameFrom = null,
         PathLengthFromStart = 0,
         HeuristicEstimatePathLength = GetHeuristicPathLength(start, goal)
     };
     openSet.Add(startNode);
     while (openSet.Count > 0)
     {
         var currentNode = openSet.OrderBy(node =>
           node.EstimateFullPathLength).First();
         if (currentNode.Position == goal)
             return GetPathForNode(currentNode);
         openSet.Remove(currentNode);
         closedSet.Add(currentNode);
         foreach (var neighbourNode in GetNeighbours(currentNode, goal, field, weightFunc))
         {
             if (closedSet.Count(node => node.Position == neighbourNode.Position) > 0)
                 continue;
             var openNode = openSet.FirstOrDefault(node =>
               node.Position == neighbourNode.Position);
             if (openNode == null)
                 openSet.Add(neighbourNode);
             else
                 if (openNode.PathLengthFromStart > neighbourNode.PathLengthFromStart)
                 {
                     openNode.CameFrom = currentNode;
                     openNode.PathLengthFromStart = neighbourNode.PathLengthFromStart;
                 }
         }
     }
     return null;
 }
コード例 #13
0
ファイル: Flag.cs プロジェクト: temik911/audio
 public Flag(Cell cell)
     : base(LogicService.flag, cell)
 {
 }
コード例 #14
0
ファイル: CustomMarker.cs プロジェクト: temik911/audio
 private CustomMarker(Texture2D texture, Cell cell)
     : base(texture, cell)
 {
 }
コード例 #15
0
ファイル: Marker.cs プロジェクト: temik911/audio
 public Marker(Texture2D texture, Cell cell)
 {
     Texture = texture;
     Cell = cell;
     Order = 0;
 }
コード例 #16
0
ファイル: Cell.cs プロジェクト: temik911/audio
 internal void createTopology()
 {
     Cell[] temp = new Cell[6];
     foreach (Cell neighbour in neighbours)
     {
         if (neighbour.Type == CellType.LAND) continue;
         if ((neighbour.I == I) && (neighbour.J == J + 1)) temp[0] = neighbour;
         if ((neighbour.I == I) && (neighbour.J == J - 1)) temp[3] = neighbour;
         if (I % 2 == 0)
         {
             if ((neighbour.I == I - 1) && (neighbour.J == J)) temp[1] = neighbour;
             if ((neighbour.I == I - 1) && (neighbour.J == J - 1)) temp[2] = neighbour;
             if ((neighbour.I == I + 1) && (neighbour.J == J - 1)) temp[4] = neighbour;
             if ((neighbour.I == I + 1) && (neighbour.J == J)) temp[5] = neighbour;
         }
         else
         {
             if ((neighbour.I == I - 1) && (neighbour.J == J + 1)) temp[1] = neighbour;
             if ((neighbour.I == I - 1) && (neighbour.J == J)) temp[2] = neighbour;
             if ((neighbour.I == I + 1) && (neighbour.J == J)) temp[4] = neighbour;
             if ((neighbour.I == I + 1) && (neighbour.J == J + 1)) temp[5] = neighbour;
         }
     }
     topology = temp.ToList<Cell>();
 }
コード例 #17
0
ファイル: Cell.cs プロジェクト: temik911/audio
 internal void addNeighbor(Cell cell)
 {
     neighbours.Add(cell);
 }
コード例 #18
0
ファイル: GameField.cs プロジェクト: temik911/audio
 public List<Cell> getPath(Cell from, Cell to, Func<Cell, Cell, float> weightFunc = null)
 {
     return new AStar().FindPath(this, from, to, weightFunc);
 }
コード例 #19
0
ファイル: GameField.cs プロジェクト: nkast/FusionFramework
 public List <Cell> getPath(Cell from, Cell to, Func <Cell, Cell, float> weightFunc = null)
 {
     return(new AStar().FindPath(this, from, to, weightFunc));
 }
コード例 #20
0
ファイル: AStar.cs プロジェクト: temik911/audio
 private int GetHeuristicPathLength(Cell from, Cell to)
 {
     return Math.Abs(from.I - to.I) + Math.Abs(from.J - to.J);
 }
コード例 #21
0
ファイル: Team.cs プロジェクト: temik911/audio
        void createBase(Cell initialCell)
        {
            List<Cell> basePoints = new List<Cell>();
            Cell temp = initialCell;
            if (temp.Type == CellType.LAND)
            {
                List<Cell> queue = new List<Cell>();
                queue.AddRange(temp.Neighbours);
                Boolean find = false;
                temp = queue[0];
                while (!find)
                    if (temp.Type != CellType.LAND)
                        find = true;
                    else
                    {
                        foreach (Cell neighbour in temp.Neighbours)
                            if (!queue.Contains(neighbour))
                                queue.Add(neighbour);
                        queue.RemoveAt(0);
                        temp = queue[0];
                    }
            }

            basePoints.Add(temp);
            for (int i = 0; i < 2; i++)
            {
                Cell c = temp.Neighbours[rnd.Next(temp.Neighbours.Count)];
                Boolean f = false;
                while ((c.Type == CellType.LAND) || (!f))
                {
                    c = temp.Neighbours[rnd.Next(temp.Neighbours.Count)];
                    f = true;
                    foreach (Cell curBase in basePoints)
                        if ((curBase.I == c.I) && (curBase.J == c.J))
                        {
                            f = false;
                            break;
                        }
                }
                basePoints.Add(c);
                temp = c;
            }
            foreach (Cell cell in basePoints) {
                this.addToCollection(new BaseC(cell, this));
            }
        }
コード例 #22
0
ファイル: Circle.cs プロジェクト: temik911/audio
 public Circle(Cell cell)
     : base(LogicService.circle, cell)
 {
 }
コード例 #23
0
ファイル: GameField.cs プロジェクト: temik911/audio
 internal void addNewNoise(Cell cell, double noise)
 {
     if (primalNoise[cell.I, cell.J] < noise) primalNoise[cell.I, cell.J] = noise;
 }
コード例 #24
0
ファイル: Check.cs プロジェクト: temik911/audio
 public Check(Cell cell)
     : base(LogicService.check, cell)
 {
 }
コード例 #25
0
ファイル: Aim.cs プロジェクト: temik911/audio
 public Aim(Cell cell)
     : base(LogicService.aim, cell)
 {
 }
コード例 #26
0
ファイル: XMark.cs プロジェクト: temik911/audio
 public XMark(Cell cell)
     : base(LogicService.xMark, cell)
 {
 }
コード例 #27
0
ファイル: GameField.cs プロジェクト: temik911/audio
        void createField()
        {
            field = new Cell[_height, _width];
            primalNoise = new double[_height, _width];

            for (int i = 0; i < _height; i++)
                for (int j = 0; j < _width; j++)
                    field[i, j] = new Cell(i, j, CellType.DEEP);

            for (int i = 0; i < _height; i++)
                for (int j = 0; j < _width; j++)
                {
                    Cell cell = field[i, j];
                    if (i - 1 >= 0) cell.addNeighbor(field[i - 1, j]);
                    if (i + 1 < _height) cell.addNeighbor(field[i + 1, j]);
                    if (j - 1 >= 0) cell.addNeighbor(field[i, j - 1]);
                    if (j + 1 < _width) cell.addNeighbor(field[i, j + 1]);
                    if (i % 2 == 1)
                    {
                        if ((i - 1 >= 0) & (j + 1 < _width)) cell.addNeighbor(field[i - 1, j + 1]);
                        if ((i + 1 < _height) & (j + 1 < _width)) cell.addNeighbor(field[i + 1, j + 1]);
                    }
                    else
                    {
                        if ((i - 1 >= 0) & (j - 1 >= 0)) cell.addNeighbor(field[i - 1, j - 1]);
                        if ((i + 1 < _height) & (j - 1 >= 0)) cell.addNeighbor(field[i + 1, j - 1]);
                    }
                }
        }