Example #1
0
    public static void moveUnit(int moves, coordinates newPosition, coordinates newCoordinates)
    {
        unitUsed = true;

        float width  = Convert.ToSingle(Camera.main.orthographicSize * 2.0 * Screen.width / 10);
        float height = Convert.ToSingle(Camera.main.orthographicSize * 2.0 * Screen.height / 10);

        unit.Card.transform.position = new Vector3(width / 4.1925f + newPosition.x * (width / 15.68f), height / 1.7348f + newPosition.y * (width / 15.68f), 0);
        unit.movesRemaining         -= moves;

        foreach (Unit u in Game_Details_UI.players[MainPresenter.currentPlayer].units.Where(s => s != null))
        {
            if (u.XLocation == unit.XLocation && u.YLocation == unit.YLocation)
            {
                u.XLocation = newCoordinates.x;
                u.YLocation = newCoordinates.y;
                break;
            }
        }

        unit.XLocation = newCoordinates.x;
        unit.YLocation = newCoordinates.y;

        destroySpots();

        if (unit.Name == "Arsonist" && (Math.Abs(newPosition.x) > 2 || newPosition.y > 2))
        {
            paused = true;
            Button[]           buttons   = MainPresenter.showButtons(String.Format("{0}", MainPresenter.player.name), "Would you like to destroy a building?", "Yes", "No");
            List <UnityAction> listeners = new List <UnityAction>();
            listeners.Add(delegate { selectBuilding(MainPresenter.player, null, true); });
            listeners.Add(delegate { finishAttack(unit, MainPresenter.player); });
            MainPresenter.addListeners(buttons.ToList(), listeners);
        }
    }
Example #2
0
    public static coordinates convertCoordinates(coordinates c, int playerIndex)
    {
        //Change current coordinates according to the way board is flipped (which is based on current player from main presenter)
        int x;
        int y;

        switch (playerIndex)
        {
        case 0:
            break;

        case 1:
            x    = c.x;
            y    = c.y;
            c.x  = y;
            c.y  = x;
            c.x *= -1;
            break;

        case 2:
            c.y *= -1;
            c.x *= -1;
            break;

        case 3:
            x    = c.x;
            y    = c.y;
            c.x  = y;
            c.y  = x;
            c.y *= -1;
            break;
        }
        return(c);
    }
Example #3
0
        public void Equality()
        {
            var a = new coordinates(2d, 3d);
            var b = new coordinates(2d, 3d);

            Assert.AreEqual(a, b);
        }
Example #4
0
        public void InfixInequality()
        {
            var a = new coordinates(2d, 3d);
            var b = new coordinates(3d, 2d);

            Assert.True(a != b);
        }
Example #5
0
    public static void makeSpace(coordinates c, selectionType type, int moves, coordinates o, UnityAction method)
    {
        float width  = Convert.ToSingle(Camera.main.orthographicSize * 2.0 * Screen.width / 10);
        float height = Convert.ToSingle(Camera.main.orthographicSize * 2.0 * Screen.height / 10);

        //When setting selections make sure to add or subtract width / 15.68f and height / 8.8138f
        GameObject selection = GameObject.Instantiate(MainPresenter.highlightedSpace, new Vector3(width / 4.1925f + c.x * (width / 15.68f), height / 1.7348f + c.y * (height / 8.8138f), 0), Quaternion.identity, MainPresenter.canvas.transform);
        Button     button    = selection.GetComponent <Button>();

        selections.Add(selection);
        coordinatesSpotted.Add(c);
        if (type == selectionType.move)
        {
            selection.GetComponent <Image>().color = new Color(0, 1, 0, 0.49f);
            button.onClick.AddListener(delegate { moveUnit(moves, c, o); });
            if (moves < unit.movesRemaining)
            {
                checkAdjacentSpaces(c, moves + 1, o, true);
            }
        }
        else if (type == selectionType.attack)
        {
            selection.GetComponent <Image>().color = new Color(1, 0, 0, 0.49f);
            button.onClick.AddListener(delegate { attackUnit(o); });
        }
        else
        {
            selection.GetComponent <Image>().color = new Color(1, 1, 0, 0.49f);
            button.onClick.AddListener(method);
        }
    }
Example #6
0
        public void InfixEquality()
        {
            var a = new coordinates(2d, 3d);
            var b = new coordinates(2d, 3d);

            Assert.True(a == b);
        }
Example #7
0
 public coordinates GetLatLngByAddress(string address)
 {
     try
     {
         var      googleAPIKey    = _config.Value.GoogleAPIKey;
         var      locationService = new GoogleLocationService(apikey: googleAPIKey);
         MapPoint point           = locationService.GetLatLongFromAddress(address);
         if (point == null)
         {
             return(null);
         }
         else
         {
             var response = new coordinates
             {
                 Latitude  = point.Latitude,
                 Longitude = point.Longitude
             };
             return(response);
         }
     }
     catch (Exception ex)
     {
         //return string.Format("Google Maps API Error {0}", ex.Message);
         return(null);
     }
 }
Example #8
0
        public void Inequality()
        {
            var a = new coordinates(2d, 3d);
            var b = new coordinates(3d, 2d);

            Assert.AreNotEqual(a, b);
        }
Example #9
0
        public RobotAction Tick(int robotId, RoundConfig config, GameState state)
        {
            RobotState  self   = state.robots[robotId];
            RobotAction action = new RobotAction();
            coordinates T_cd   = new coordinates();
            coordinates P_cd   = new coordinates();

            List <string> friendRobots = new List <string>()
            {
                "Ryzhov", "Haritonov", "Nikandrov", "Sinyavsky", "Frolov", "Orlov", "Kamshilov"
            };

            AttackToDefence(ref action, self);
            if ((self.energy > 0.7 * config.max_energy) && (check == true))
            {
                T_cd      = getNearestRobot(config, state, self);
                P_cd      = MoveTo(config, self, T_cd);
                action.dX = P_cd.x;
                action.dY = P_cd.y;
            }
            else
            {
                check     = false;
                T_cd      = EnergyPoint(config, state, self);
                P_cd      = MoveTo(config, self, T_cd);
                action.dX = P_cd.x;
                action.dY = P_cd.y;
                if (self.energy >= 0.999 * config.max_energy)
                {
                    check = true;
                }
            }
            action.targetId = -1;
            return(action);
        }
Example #10
0
        public void From_WorldVector_South()
        {
            var expected = new coordinates(2d, 3d * math.PI_DBL / 2d);
            var actual   = new coordinates(new double2(0d, -2d));

            Assert.AreEqual(expected.r, actual.r, tolerance);
            Assert.AreEqual(expected.theta.radians, actual.theta.radians, tolerance);
        }
Example #11
0
    void changeOrientation(coordinates c, int moves)
    {
        coordinates originalCoordinates = c;

        c = convertCoordinates(c, MainPresenter.currentPlayer);

        checkAdjacentSpaces(c, moves, originalCoordinates, true);
    }
Example #12
0
        public void ObjectEquality()
        {
            var a = new coordinates(2d, 3d);
            var b = new coordinates(3d, 2d);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
        }
Example #13
0
    public static void spotCheck(coordinates c, int moves, coordinates o, bool adjacentAttack)
    {
        //Check if already in list of spots
        foreach (coordinates cs in coordinatesSpotted)
        {
            if (cs.x == c.x && cs.y == c.y)
            {
                return;
            }
        }

        //Check if that is the current unit's spot, if so skip it
        coordinates unitLocation = new coordinates();

        unitLocation.x = (int)unit.XLocation;
        unitLocation.y = (int)unit.YLocation;
        unitLocation   = convertCoordinates(unitLocation, MainPresenter.currentPlayer);
        if (c.x == unitLocation.x && c.y == unitLocation.y)
        {
            return;
        }

        foreach (coordinates cToAvoid in coordinatesToAttack)
        {
            coordinates attack = convertCoordinates(cToAvoid, MainPresenter.currentPlayer);
            if (attack.x == c.x && attack.y == c.y)
            {
                //Check if unit is out of attacks and if enemy is adjacent
                if (unit.attacksRemaining != 0 && unit.Name == "archer")
                {
                    if (moves == 1)
                    {
                        makeSpace(c, selectionType.attack, moves, o, null);
                    }
                    else if (moves == 2)
                    {
                        makeSpace(c, selectionType.attack, moves, o, null);
                    }
                }
                else if (unit.attacksRemaining != 0 && moves == 1)
                {
                    makeSpace(c, selectionType.attack, moves, o, null);
                }
                return;
            }
        }

        if (unit.attacksRemaining != 0 && unit.Name == "archer" && moves < 2)
        {
            checkAdjacentSpaces(c, 2, o, false);
        }

        //Check if unit is out of moves and within their personal movement range (units cannot move into other player's castles)
        if (unit.movesRemaining != 0 && (Math.Abs(c.x) <= 2 && c.y <= 2) && adjacentAttack)
        {
            makeSpace(c, selectionType.move, moves, o, null);
        }
    }
Example #14
0
        public void ToWorldVector()
        {
            var c        = new coordinates(2d, math.PI_DBL / 2d);
            var expected = new double2(0d, 2d);
            var actual   = c.ToWorldVector();

            Assert.AreEqual(expected.x, actual.x, tolerance);
            Assert.AreEqual(expected.y, actual.y, tolerance);
        }
Example #15
0
        public void Hashing()
        {
            var a_1 = new coordinates(2d, 3d);
            var a_2 = new coordinates(2d, 3d);
            var b   = new coordinates(3d, 2d);

            Assert.True(a_1.GetHashCode() == a_2.GetHashCode());
            Assert.True(a_1.GetHashCode() != b.GetHashCode());
        }
Example #16
0
        public void From_WorldVector_SouthNegative_WithAngle()
        {
            var theta    = new angle(-math.PI_DBL / 2d);
            var expected = new coordinates(2d, theta);
            var actual   = new coordinates(new double2(0d, -2d));

            Assert.AreEqual(expected.r, actual.r, tolerance);
            Assert.AreEqual(expected.theta.radians, actual.theta.radians, tolerance);
        }
Example #17
0
        public void ToWorldVector_PolarVector()
        {
            var c        = new coordinates(1d, math.PI_DBL / 2d);
            var v_polar  = new double2(2d, 3d);
            var expected = new double2(-2d, 4d);
            var actual   = c.ToWorldVector(v_polar);

            Assert.AreEqual(expected.x, actual.x, tolerance);
            Assert.AreEqual(expected.y, actual.y, tolerance);
        }
Example #18
0
        public void PolarTransform_Vector()
        {
            var c        = new coordinates(1d, math.PI_DBL / 2d);
            var v_world  = new double2(-2d, 3d);
            var expected = new double2(2d, 3d);
            var actual   = c.PolarTransform(v_world);

            Assert.AreEqual(expected.x, actual.x, tolerance);
            Assert.AreEqual(expected.y, actual.y, tolerance);
        }
Example #19
0
        public static string isPossible(int a, int b, int c, int d)
        {
            coordinates goal  = new coordinates(c, d);
            coordinates point = new coordinates(a, b);

            int targettedXDifference = goal.X - point.X;
            int targettedYDifference = goal.Y - point.Y;

            return("notcompletedd");
        }
Example #20
0
        public void ThetaHat()
        {
            var c = new coordinates(2d, math.PI_DBL / 2d);
            // Increasing theta is in the negative-x direction.
            var expected = new double2(-1d, 0d);
            var actual   = c.ThetaHat();

            Assert.AreEqual(expected.x, actual.x, tolerance);
            Assert.AreEqual(expected.y, actual.y, tolerance);
        }
Example #21
0
        public void WorldTransform()
        {
            var c        = new coordinates(1d, math.PI_DBL / 2d);
            var v_polar  = new double2(2d, 3d);
            var T_world  = c.WorldTransform();
            var expected = new double2(-2d, 3d);
            var actual   = math.mul(T_world, v_polar);

            Assert.AreEqual(expected.x, actual.x, tolerance);
            Assert.AreEqual(expected.y, actual.y, tolerance);
        }
Example #22
0
 public IntroEffects(Texture2D sparkTexture, Random random)
 {
     this.particleTexture = sparkTexture;
     this.type            = random.Next(3);
     crd = new coordinates(
         TestGame.Width * -0.5f,
         TestGame.Width * -0.2f,
         TestGame.Width * 2 / 3,
         TestGame.Height * 1.4f,
         TestGame.Height * 1.2f, 0);
 }
Example #23
0
        public void Formatting()
        {
            var a_r     = 2d;
            var a_theta = new angle(3d);
            var a       = new coordinates(a_r, a_theta.radians);

            Assert.AreEqual(
                $"coordinates(r: {a_r}, theta: {a_theta})",
                a.ToString()
                );
        }
Example #24
0
        private void buildOutPutPoint(coordinates column, neuronDirection direction, Int16 layer)
        {
            coordinates freeLocation = getClosestFreeSpace(column, layer);

            matrix.mainMatrix[freeLocation.y].neuronLayer[freeLocation.x][freeLocation.z][freeLocation.t] = new Neurons.NeuronOutput(ref matrix, direction);

            freeLocation = getClosestFreeSpace(column, layer);
            matrix.mainMatrix[freeLocation.y].neuronLayer[freeLocation.x][freeLocation.z][freeLocation.t] = new Neurons.NeuronPyramidal(ref matrix, direction);

            freeLocation = getClosestFreeSpace(column, layer);
            matrix.mainMatrix[freeLocation.y].neuronLayer[freeLocation.x][freeLocation.z][freeLocation.t] = new Neurons.NeuronTransfer(ref matrix, direction);
        }
Example #25
0
        private void buildProcessingNeuron(coordinates column, neuronDirection direction, Int16 layer)
        {
            coordinates freeLocation = getClosestFreeSpace(column, layer);

            matrix.mainMatrix[freeLocation.y].neuronLayer[freeLocation.x][freeLocation.z][freeLocation.t] = new Neurons.NeuronExitor(direction, ref matrix);

            freeLocation = getClosestFreeSpace(freeLocation, layer);
            matrix.mainMatrix[freeLocation.y].neuronLayer[freeLocation.x][freeLocation.z][freeLocation.t] = new Neurons.NeuronInhibitor(direction, ref matrix);

            freeLocation = getClosestFreeSpace(freeLocation, layer);
            matrix.mainMatrix[freeLocation.y].neuronLayer[freeLocation.x][freeLocation.z][freeLocation.t] = new Neurons.NeuronExitor(direction, ref matrix);
        }
Example #26
0
        public void RelativeToWorldVector()
        {
            var pos      = new coordinates(2d, -math.PI_DBL / 2d);
            var v_polar  = new double2(-2d, -2d);
            var expected = new coordinates(2d, math.PI_DBL);
            var actual   = pos.Update(v_polar);

            Assert.AreEqual(expected.r, actual.r, tolerance);
            Assert.AreEqual(
                angle.wrap(expected.theta.radians),
                angle.wrap(actual.theta.radians),
                tolerance
                );
        }
Example #27
0
        protected coordinates Cortege(GameState gs, RobotState myself)
        {
            coordinates point = new coordinates();

            foreach (RobotState r in gs.robots)
            {
                if ((r.isAlive == true) && (r.name == "Ryzhov"))
                {
                    point.x = r.X;
                    point.y = r.Y;
                }
            }
            return(point);
        }
        public CoordinateMarker(double mercatorX, double mercatorY, bool changeToDms = false)
        {
            InitializeComponent();

            this._current = coordinates.Geodetic;

            this.ChangeToDms = changeToDms;

            this.MercatorLocation = new IRI.Ham.SpatialBase.Point(mercatorX, mercatorY);

            //this.X = mercatorX;

            //this.Y = mercatorY;
        }
Example #29
0
        private void buildInputLayer()
        {
            List <PointF> inputNeuronLocations = utilities.getInputPoints(y, z, byteSize);

            inputBytes = new List <coordinates[]>();

            matrix                        = new Matrix();
            matrix.inputPoints            = inputNeuronLocations;
            matrix.mainMatrix             = new Layer[x];
            matrix.mainMatrix[inputLayer] = new Layer(y, z, t);
            coordinates[] tmpList  = new coordinates[byteSize];
            Int16         bitcount = 0;

            foreach (PointF inploc in inputNeuronLocations)
            {
                if (matrix.mainMatrix[inputLayer].neuronLayer[(Int16)inploc.X] == null)
                {
                    matrix.mainMatrix[inputLayer].neuronLayer[(Int16)inploc.X] = new Neurons.INeuron[y][];
                }

                if (matrix.mainMatrix[inputLayer].neuronLayer[(Int16)inploc.X][(Int16)inploc.Y] == null)
                {
                    matrix.mainMatrix[inputLayer].neuronLayer[(Int16)inploc.X][(Int16)inploc.Y] = new Neurons.INeuron[t];
                }

                if (matrix.mainMatrix[inputLayer].neuronLayer[(Int16)inploc.X][(Int16)inploc.Y][0] == null)
                {
                    matrix.mainMatrix[inputLayer].neuronLayer[(Int16)inploc.X][(Int16)inploc.Y][0] = new Neurons.NeuronInput(ref matrix, neuronDirection.up);

                    coordinates tmp = new coordinates();
                    tmp.y = inputLayer;
                    tmp.x = (Int16)inploc.X;
                    tmp.z = (Int16)inploc.Y;
                    tmp.t = 0;

                    buildInputLayerColumns(tmp);
                    tmpList[bitcount] = tmp;
                    if (bitcount == byteSize)
                    {
                        inputBytes.Add(tmpList);
                        bitcount = 0;
                        tmpList  = new coordinates[byteSize];
                    }
                }

                bitcount++;
            }
        }
Example #30
0
        public coordinates EnergyPoint(RoundConfig config, GameState state, RobotState self)
        {
            int         dt       = config.width * config.height;
            coordinates cd_point = new coordinates();

            foreach (Point p in state.points)
            {
                if ((p.type == PointType.Energy) && (Distance(self.X, self.Y, p.X, p.Y) < dt))
                {
                    cd_point.x = p.X;
                    cd_point.y = p.Y;
                    dt         = Distance(self.X, self.Y, p.X, p.Y);
                }
            }
            return(cd_point);
        }
 public virtual List<ptsPoint> getPoints(coordinates.CurvilinearCoordinates.StationOffsetElevation anSOE)
 {
     throw new NotImplementedException();
 }
        public override List<ptsPoint> getPoints(coordinates.CurvilinearCoordinates.StationOffsetElevation anSOE)
        {
            var returnList = new List<ptsPoint>();

             foreach (var segment in allChildSegments)
             {
            returnList.AddRange(segment.getPoints(anSOE));
             }

             return returnList;
        }