Пример #1
0
 internal static void schedule <T>(ICollection <QueueItem <T> > queueItems, MapPosition mapPosition, int tileSize) where T : Job
 {
     foreach (QueueItem <T> queueItem in queueItems)
     {
         queueItem.Priority = calculatePriority([email protected], mapPosition, tileSize);
     }
 }
Пример #2
0
        public MapDetailView() : base("MapDetailView", null)
        {
            this.WhenActivated(d =>
            {
                d(this.WhenAny(v => v.ViewModel.IsLoading, x => x.Value).Subscribe(loading =>
                {
                    LoadingRing.Hidden = !loading;
                }));

                d(this.WhenAny(v => v.ViewModel.CurrentCoordinates, x => x.Value).Where(v => v != null).Subscribe(center =>
                {
                    var coordinate = new CLLocationCoordinate2D(center.Latitude, center.Longitude);
                    MapPosition.AddAnnotations(new MKPointAnnotation()
                    {
                        Title      = "Aqui estamos!",
                        Coordinate = coordinate
                    });
                    MapPosition.SetCamera(new MKMapCamera()
                    {
                        CenterCoordinate = coordinate,
                        Heading          = center.Heading < 0 ? 0 : center.Heading,
                        Altitude         = 75,
                        Pitch            = 75
                    }, true);
                }));

                ViewModel.GetCurrentCoordinatesCommand.Execute(null);
            });
        }
Пример #3
0
        private void sceneNavigated(object sender, NavigationEventArgs args)
        {
            var toPosition = new MapPosition(args.Scene.MapPosition.X, args.Scene.MapPosition.Y);

            switch (args.Direction)
            {
            case Direction.North:
                toPosition.Y -= 1;
                break;

            case Direction.South:
                toPosition.Y += 1;
                break;

            case Direction.East:
                toPosition.X += 1;
                break;

            case Direction.West:
                toPosition.X -= 1;
                break;
            }

            var nextScene = Scenes.FirstOrDefault(s => s.MapPosition.X == toPosition.X && s.MapPosition.Y == toPosition.Y);

            if (nextScene != null)
            {
                DataProvider.StartPosition = nextScene.MapPosition;
                nextScene.Enter(player);
            }
        }
Пример #4
0
        private Node.NodeType CheckNodeType(MapPosition mapPosition)
        {
            if (BoxCast(mapPosition))
            {
                //Inside an object
                return(Node.NodeType.Blocked);
            }
            var x = mapPosition.X;
            var y = mapPosition.Y;

            if (!BoxCast(x, y - 1))
            {
                return(Node.NodeType.Empty);
            }
            //Is on solid ground, check for edges
            var leftLowBoxCast  = BoxCast(x - 1, y - 1);
            var rightLowBoxCast = BoxCast(x + 1, y - 1);
            var leftBoxCast     = BoxCast(x - 1, y);
            var rightBoxCast    = BoxCast(x + 1, y);

            if (leftLowBoxCast && rightLowBoxCast && !leftBoxCast && !rightBoxCast)
            {
                return(Node.NodeType.Platform);
            }
            if (leftLowBoxCast || leftBoxCast)
            {
                return(Node.NodeType.RightEdge);
            }
            if (rightLowBoxCast || rightBoxCast)
            {
                return(Node.NodeType.LeftEdge);
            }
            return(Node.NodeType.Solo);
        }
Пример #5
0
 private void Reset()
 {
     mapMinPos       = new MapPosition(0, 0);
     mapMaxPos       = new MapPosition(20, 20);
     NodeSize        = Vector2.one;
     NodeBoxCastSize = new Vector2(0.9f, 0.9f);
 }
Пример #6
0
    private bool SetEndPoint()
    {
        if (!Input.GetMouseButtonDown(0))
        {
            return(false);
        }

        var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (!Physics.Raycast(ray, out hit, float.MaxValue, LayerMask.GetMask("Ground")))
        {
            return(false);
        }

        int x = Mathf.RoundToInt(hit.point.x);
        int y = Mathf.RoundToInt(-hit.point.z);

        _originMap[y, x] = POINT_END;

        _endPoint = new MapPosition(y, x);
        var spawnPos = new Vector3(_endPoint.PosY, hit.point.y, -_endPoint.PosX);

        _endPointGameObject = Instantiate(_prefabPoint, spawnPos, Quaternion.identity);

        return(true);
    }
Пример #7
0
    private void CheckMouse()
    {
        Vector3 worldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        //float fx = worldPos.x + 7.5f;
        //int y = (int) Mathf.Floor(worldPos.y - 1.5f)*-1;

        //if (y%2 != 0) {
        //    fx += 0.5f;
        //}

        //int x = (int) Mathf.Floor(fx);

        MapPosition gridPosition = CombatManager.WorldToGrid(worldPos);

        int x = gridPosition.x;
        int y = gridPosition.y;


        // TODO: every second row
        if (0 <= x && x <= 15)
        {
            if (selectedCard != null && Input.GetMouseButtonDown(0))
            {
                if (CanUseSpell(selectedCard.GetBaseCard(), x, y))
                {
                    UseCard(selectedCard.GetBaseCard(), x, y);
                    Destroy(selectedCard.gameObject);
                }
                // Deselect card on failed attempt for now
                selectedCard = null;
            }
        }
    }
Пример #8
0
        public JsonResult ViewHouses()
        {
            Hashtable ht = new Hashtable();

            DataTable dt = dbUtility.GetDataBySQLString("SELECT Latitude, Longitude, Phone, price, HouseType, Name, LocationDescription FROM RentalHouse left join UserMaster on RentalHouse.UserId=UserMaster.UserId");

            var mapPosList = new List <MapPosition>();

            foreach (DataRow dr in dt.Rows)
            {
                MapPosition mapPos = new MapPosition();

                mapPos.Latitude    = Convert.ToDecimal(dr["Latitude"].ToString());
                mapPos.Longitude   = Convert.ToDecimal(dr["Longitude"].ToString());
                mapPos.Description = dr["LocationDescription"].ToString();
                mapPos.Price       = dr["Price"].ToString();
                mapPos.Contact     = dr["phone"].ToString();
                mapPos.HouseType   = dr["HouseType"].ToString();
                mapPos.UserName    = dr["Name"].ToString();
                mapPosList.Add(mapPos);
            }

            return(Json(new { MyList = mapPosList }, JsonRequestBehavior.AllowGet));
            // return Json(true , JsonRequestBehavior.AllowGet);
        }
Пример #9
0
        public override CGObject ReadObject(BinaryReader reader, int objectId, MapPosition objectPosition)
        {
            CGPandoraBox box = new CGPandoraBox();

            ReadMessageAndGuards(reader, box);

            box.GainExperience = reader.ReadUInt32();
            box.ManaDiff       = reader.ReadUInt32();
            box.MoraleDiff     = reader.ReadByte();
            box.LuckDiff       = reader.ReadByte();

            box.GainResources = ReadResources(reader);

            box.GainPrimarySkills = new List <int>(4);
            for (int x = 0; x < 4; ++x)
            {
                box.GainPrimarySkills.Add(reader.ReadByte());
            }

            box.GainSecondarySkills = new List <ESecondarySkill>();
            box.GainAbilityLevels   = new List <int>();
            int gabn = reader.ReadByte();//number of gained abilities

            for (int oo = 0; oo < gabn; ++oo)
            {
                box.GainSecondarySkills.Add((ESecondarySkill)reader.ReadByte());
                box.GainAbilityLevels.Add(reader.ReadByte());
            }

            box.GainArtifacts = new List <EArtifactId>();
            int gart = reader.ReadByte(); //number of gained artifacts

            for (int oo = 0; oo < gart; ++oo)
            {
                if (MapHeader.Version > EMapFormat.ROE)
                {
                    box.GainArtifacts.Add((EArtifactId)reader.ReadUInt16());
                }
                else
                {
                    box.GainArtifacts.Add((EArtifactId)reader.ReadByte());
                }
            }

            box.GainSpells = new List <ESpellId>();
            int gspel = reader.ReadByte(); //number of gained spells

            for (int oo = 0; oo < gspel; ++oo)
            {
                box.GainSpells.Add((ESpellId)reader.ReadByte());
            }

            box.GainCreatures = new CreatureSet();
            int gcre = reader.ReadByte(); //number of gained creatures

            box.GainCreatures = ReadCreatureSet(reader, gcre);
            reader.Skip(8);

            return(box);
        }
Пример #10
0
    /// <summary>
    /// Moves the permanent based on its movement stats
    /// </summary>
    /// <param name="permanent">Permanent to make move</param>
    private static void Move(CreatureStats permanent)
    {
        MapPosition from = permanent.GridPosition;

        permanentMap[permanent.GridPosition.x, permanent.GridPosition.y] = null;

        MapPosition to = permanent.GetForward();

        permanentMap[to.x, to.y] = permanent;
        permanent.GridPosition   = to;

        permanent.GetComponent <Animator>().SetBool("IsWalking", true);

        // Move it and set animating state
        LeanTween.move(permanent.gameObject, GridToWorld(to), AnimationMoveDuration).
        setOnComplete(() =>
        {
            if (!permanent)
            {
                return;
            }
            permanent.GetComponent <Animator>().SetBool("IsWalking", false);
        });

        StateManager.RegisterAnimation(AnimationMoveDuration);
        //permanent.transform.position = GridToWorld(to);

        EventManager.InvokePermanentMoved(permanent, from, to);
    }
Пример #11
0
    /// <summary>
    /// Returns what zone the targeted tile is considered to belong to, from faction's perspective.
    /// </summary>
    /// <param name="pos">The tile to check</param>
    /// <param name="faction">The faction to check for</param>
    /// <returns></returns>
    public static CombatZone GetZone(MapPosition pos, Owner faction)
    {
        switch (faction)
        {
        case Owner.ENEMY:
            if (pos.x >= 14 - 4)
            {
                return(CombatZone.Friendly);
            }
            else if (pos.x >= 5)
            {
                return(CombatZone.Neutral);
            }
            else
            {
                return(CombatZone.Hostile);
            }

        case Owner.PLAYER:
            if (pos.x >= 14 - 4)
            {
                return(CombatZone.Hostile);
            }
            else if (pos.x >= 5)
            {
                return(CombatZone.Neutral);
            }
            else
            {
                return(CombatZone.Friendly);
            }
        }
        throw new Exception("Something seems to have went wrong with combat zones. Unhandled case of new type?");
    }
Пример #12
0
        private void HandleEffectSummonVanityPet(UnitEntity target, SpellTargetInfo.SpellTargetEffectInfo info)
        {
            if (!(target is Player player))
            {
                return;
            }

            // enqueue removal of existing vanity pet if summoned
            if (player.VanityPetGuid != null)
            {
                VanityPet oldVanityPet = player.GetVisible <VanityPet>(player.VanityPetGuid.Value);
                oldVanityPet?.RemoveFromMap();
                player.VanityPetGuid = 0u;
            }

            var vanityPet = new VanityPet(player, info.Entry.DataBits00);

            var position = new MapPosition
            {
                Position = player.Position
            };

            if (player.Map.CanEnter(vanityPet, position))
            {
                player.Map.EnqueueAdd(vanityPet, position);
            }
        }
Пример #13
0
        private SLAMTransfer GetTransferBySection(MapSection section)
        {
            SLAMTransfer temp = new SLAMTransfer();

            temp.Step1Offset = slamPosition[section.FromAddress.Id].Position;
            temp.Step4Offset = section.FromAddress.AGVPosition.Position;

            temp.Step3Mag = section.Distance / computeFunction.GetTwoPositionDistance(slamPosition[section.FromAddress.Id].Position, slamPosition[section.ToAddress.Id].Position);

            double      mapAngle = computeFunction.ComputeAngle(section.FromAddress.AGVPosition.Position, section.ToAddress.AGVPosition.Position);
            MapPosition start    = new MapPosition(slamPosition[section.FromAddress.Id].Position.X, -slamPosition[section.FromAddress.Id].Position.Y);
            MapPosition end      = new MapPosition(slamPosition[section.ToAddress.Id].Position.X, -slamPosition[section.ToAddress.Id].Position.Y);

            double slamAngle = computeFunction.ComputeAngle(start, end);

            temp.ThetaOffset = mapAngle - slamAngle;

            // theta 要帶-/+?
            temp.Step2Sin         = Math.Sin(-temp.ThetaOffset * Math.PI / 180);
            temp.Step2Cos         = Math.Cos(-temp.ThetaOffset * Math.PI / 180);
            temp.ThetaOffset      = (slamPosition[section.FromAddress.Id].Angle + slamPosition[section.ToAddress.Id].Angle) / 2;
            temp.ThetaOffsetStart = section.FromVehicleAngle + slamPosition[section.FromAddress.Id].Angle + (section.FromAddress.AGVPosition.Angle - section.FromVehicleAngle);
            temp.ThetaOffsetEnd   = section.ToVehicleAngle + slamPosition[section.ToAddress.Id].Angle + (section.ToAddress.AGVPosition.Angle - section.ToVehicleAngle);

            double angle = computeFunction.ComputeAngle(start, end);

            temp.SinTheta = Math.Sin(-angle * Math.PI / 180);
            temp.CosTheta = Math.Cos(-angle * Math.PI / 180);
            temp.Distance = computeFunction.GetTwoPositionDistance(start, end);

            return(temp);
        }
Пример #14
0
 public Tile CorrectMapPosition(MapPosition pos)
 {
     if (!IsWithinBounds(pos))
     {
         int x = pos.X;
         int y = pos.Y;
         if (x >= Width)
         {
             x = Width - 1;
         }
         else if (x < 0)
         {
             x = 0;
         }
         if (y >= Height)
         {
             y = Height - 1;
         }
         else if (y < 0)
         {
             y = 0;
         }
         return(TileAtMapPosition(new MapPosition(x, y)));
     }
     else
     {
         return(tiles[pos.X, pos.Y]);
     }
 }
Пример #15
0
 private void OnCreatureSpawned(CreatureStats permanent, MapPosition pos)
 {
     if (permanent == ownerStats)
     {
         CheckZoneBonus();
     }
 }
Пример #16
0
        public override CGObject ReadObject(BinaryReader reader, int objectId, MapPosition objectPosition)
        {
            CGGarrison garrison = new CGGarrison();

            EPlayerColor color = (EPlayerColor)reader.ReadByte();

            garrison.SetOwner(color);

            reader.Skip(3);

            CreatureSet creatureSet = ReadCreatureSet(reader, 7);

            if (MapHeader.Version > EMapFormat.ROE)
            {
                garrison.RemovableUnits = reader.ReadBoolean();
            }
            else
            {
                garrison.RemovableUnits = true;
            }

            reader.Skip(8);

            return(garrison);
        }
Пример #17
0
    private void OnTileClick(MapPosition tilePosition, bool isLongTap)
    {
        var handleNormalTap = !isLongTap;
        if (!handleNormalTap)
        {
            var character = this._battleModel.GetCharacterAtPosition(tilePosition);
            handleNormalTap = character == null;
            if (character != null)
            {
                this._statsView.Init(character);
            }
            else
            {
                handleNormalTap = true;
            }
        }

        if (handleNormalTap)
        {
            switch (this._battleModel.CurrentPhase)
            {
                case BattleModel.BattlePhase.ActionSelect:
                    this._battleModel.MoveCurrentCharacter(tilePosition);
                    break;
                case BattleModel.BattlePhase.TargetSelect:
                    this._battleModel.TriggerCurrentSelectedSkill(tilePosition);
                    break;
                default:
                    break;
            }
        }
    }
    // Use this for initialization
    void Start()
    {
        posX         = (int)this.GetComponent <Transform>().position.x;
        posY         = -(int)this.GetComponent <Transform>().position.y;
        defaultColor = this.GetComponent <Renderer>().material.color;
        mapPosition  = GameObject.Find("ObjectManager").GetComponent <MapPosition>();
        //Debug.Log(mapPosition);
        mapPosition.charamap[posX, posY] = gameObject;
        actionFlag       = true;
        hp               = maxhp;
        battleMapManager = GameObject.Find("BattleMapManager").GetComponent <BattleMapManager>();

        //defaultColor = this.GetComponent<Renderer>().material.color;
        //mapPosition = GameObject.Find("ObjectManager").GetComponent<MapPosition>();
        //Debug.Log(mapPosition);
        //mapPosition.charamap[posX, posY] = gameObject;
        //if (occupation == 1)//主人公
        //{
        //    occupatoinDistance = 3;

        //}

        //if (occupation == 2)//盾持ち
        //{
        //    occupatoinDistance = 3;
        //}

        //if (occupation == 3)//弓兵
        //{
        //    occupatoinDistance = 3;
        //}

        //if (occupation == 4)//魔法使い
        //    occupatoinDistance = 3;//基本的に味方の行動範囲は3マス
    }
Пример #19
0
 void Awake()
 {
     mapPosition    = GetComponent <MapPosition>();
     randomPosition = GetComponent <RandomPosition>();
     // float [,] lala = mapPosition.GetMapPosition();
     // Debug.Log(lala[0, 1]);
 }
Пример #20
0
 static TileInfo GetTileInfoEmptyMap(MapPosition position)
 {
     return(new TileInfo
     {
         IsBlockingVisibility = false
     });
 }
Пример #21
0
    public bool AreNeighbors(MapPosition p0, MapPosition p1)
    {
        List <Tile> neighbors = GetNeighborsIncBlocked(p0);
        Tile        second    = TileAtMapPosition(p1);

        return(neighbors.Contains(second));
    }
 public GameObject(string Id ,MapPosition InitPosition) {
     InitializeComponent();
     this.Id = Id;
     Position = InitPosition;
     HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
     VerticalAlignment = System.Windows.VerticalAlignment.Top;
 }
Пример #23
0
 public void TestCreatePositionToTheLeftAndUp()
 {
     var position = new MapPosition(4, 5);
     var newPosition = new MapPosition(position, new PositionChange {X = -1, Y = 1});
     Assert.AreEqual(3, newPosition.X);
     Assert.AreEqual(6, newPosition.Y);
 }
Пример #24
0
        /// <summary>
        /// Draws the map tiles
        /// </summary>
        /// <param name="renderer">gui renderer</param>
        private void DrawMapTiles(IGuiRenderer renderer)
        {
            MapPosition centerPosition = this.viewModel.MapCenterPosition;

            for (int screenX = 0; screenX < this.sizeInTiles.X; screenX++)
            {
                for (int screenY = 0; screenY < this.sizeInTiles.Y; screenY++)
                {
                    int mapX     = screenX + centerPosition.X - (this.sizeInTiles.X / 2);
                    int mapY     = screenY + centerPosition.Y - (this.sizeInTiles.Y / 2);
                    var position = new MapPosition(mapX, mapY);

                    if (!this.viewModel.IsTileVisible(position))
                    {
                        continue;
                    }

                    TileInfo tileInfo = this.viewModel.GetTileInfo(position);
                    if (tileInfo != null)
                    {
                        this.DrawTile(renderer, tileInfo.TileIndex, screenX, screenY);
                    }
                }
            }
        }
Пример #25
0
    /// <summary>
    /// Returns the distances in tiles (how many tiles you would have to walk) between two positions
    /// </summary>
    /// <param name="a">From position</param>
    /// <param name="b">To position</param>
    /// <returns>Distance in tiles</returns>
    public static int Distance(MapPosition a, MapPosition b)
    {
        float deltaX  = Mathf.Pow(a.x - b.x, 2);
        float deltaY  = Mathf.Pow(a.y - b.y, 2);
        float squared = Mathf.Sqrt(deltaX + deltaY);

        return((int)Mathf.Round(squared));
    }
Пример #26
0
    private MapPosition getRandomMapPosition()
    {
        MapPosition pos = new MapPosition();

        pos.x = Random.Range(0, mapController.getMapWidth());
        pos.y = Random.Range(0, mapController.getMapHeight());
        return(pos);
    }
Пример #27
0
 public void UpdatePosition(MapPosition mapPosition)
 {
     if (this.lineRenderer == null)
     {
         this.lineRenderer = this.gameObject.GetComponent <LineRenderer>();
     }
     this.lineRenderer.SetPositions(mapPosition.CalculateAirfieldPositions());
 }
Пример #28
0
 // Overload
 public GameTile GetTileAt(MapPosition pos)
 {
     if (pos.x >= width || pos.y >= height)
     {
         return(null);
     }
     return(mapData[pos.x + 1, pos.y + 1]);
 }
Пример #29
0
 public bool Equals(MapPosition other)
 {
     if (other == null)
     {
         return(false);
     }
     return(x == other.x && y == other.y);
 }
Пример #30
0
        public override void DrawWithEffect(SpriteBatch spriteBatch)
        {
            var drawPosition = MapPosition.GetScreenPosition();

            drawPosition.Y -= MapPoint.TileHeight_Half + MapPoint.TileHeight; // this calculation may not be related to these values, not sure whats up here
            drawPosition.X += 5;                                              // just a little bump
            spriteBatch.Draw(animatedSprite[Facing], drawPosition);
        }
Пример #31
0
 public bool Equals(MapPosition obj)
 {
     if (x == obj.x && y == obj.y)
     {
         return(true);
     }
     return(false);
 }
    private void onCreatureSpawned(CreatureStats creature, MapPosition position)
    {
        GameObject newDisplay = Instantiate(StatDisplayPrefab) as GameObject;

        newDisplay.transform.SetParent(creature.transform, true);
        newDisplay.GetComponent <StatDisplayBehaviour>().SetOwner(creature);
        newDisplay.GetComponent <RectTransform>().anchoredPosition = new Vector3(0f, -0.5f, -0.5f);
    }
Пример #33
0
        public override void DrawWithoutEffect(SpriteBatch spriteBatch)
        {
            var drawPosition = MapPosition.GetScreenPosition();

            drawPosition.Y -= Sprite.Height - MapPoint.TileHeight;
            drawPosition.X -= Sprite.Width / 2;
            spriteBatch.Draw(Sprite, drawPosition, Color.White);
        }
Пример #34
0
    public bool Equals(MapPosition p)
    {
        // If parameter is null return false:
        if ((object)p == null)
        {
            return false;
        }

        // Return true if the fields match:
        return (this.X == p.X) && (this.Y == p.Y) && (this.Team == p.Team);
    }
Пример #35
0
 public int GetXDistance(MapPosition otherPosition)
 {
     if (this.Team != otherPosition.Team)
     {
         return this.X + otherPosition.X + 1;
     }
     else
     {
         return Math.Abs(this.X - otherPosition.X);
     }
 }
Пример #36
0
        public void TestEquality()
        {
            var position = new MapPosition(5, 5);
            var samePosition = new MapPosition(5, 5);
            var otherXPosition = new MapPosition(3, 5);
            var otherYPosition = new MapPosition(5, 7);

            // general
            Assert.AreEqual(position, position);
            Assert.AreNotEqual(position, null);
            Assert.AreNotEqual(position, new object());
            // MapPosition
            Assert.AreEqual(position, samePosition);
            Assert.AreEqual(position, (object)samePosition);
            Assert.AreNotEqual(position, otherXPosition);
            Assert.AreNotEqual(position, otherYPosition);
        }
Пример #37
0
        public static double MathGeoDistance(MapPosition pos1, MapPosition pos2, bool miles = false)
        {
            const double pi80 = Math.PI / 180;
            pos1.Latitude *= pi80;
            pos1.Longitude *= pi80;
            pos2.Latitude *= pi80;
            pos2.Longitude *= pi80;

            const double radEarth = 6372.707; //means radius of earth in KM
            var dLat = pos2.Latitude - pos1.Latitude;
            var dLong = pos2.Longitude - pos1.Longitude;
            var a =
                Math.Sin(dLat / 2) * Math.Sin(dLat / 2) +
                Math.Cos(pos1.Latitude) * Math.Cos(pos2.Latitude) * Math.Sin(dLong / 2) * Math.Sin(dLong / 2);
            var c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
            var km = radEarth * c;
            return miles ? km * 0.621371192 : km;
        }
Пример #38
0
    private IEnumerable<KeyValuePair<MapPosition, TileController>> InitGrid(GridLayoutGroup grid, int numberOfRows, int numberOfColumns, Const.Team team, Action<MapPosition, bool> onTileClick)
    {
        grid.constraint = GridLayoutGroup.Constraint.FixedColumnCount;
        grid.constraintCount = numberOfColumns;
        for (int i = 0; i < numberOfRows; i++)
        {
            for (int j = 0; j < numberOfColumns; j++)
            {
                var mapPosition = new MapPosition(j, i, team);

                var tile = Instantiate(tilePrefab) as GameObject;
                tile.transform.SetParent(grid.transform);
                tile.transform.localScale = Vector3.one;
                tile.transform.localEulerAngles = Vector3.zero;
                tile.transform.localPosition = Vector3.zero;

                var tileController = tile.GetComponent<TileController>();
                tileController.Init(mapPosition, onTileClick);

                yield return new KeyValuePair<MapPosition, TileController>(mapPosition, tileController);
            }
        }
    }
Пример #39
0
 private void SetCharacterSelectedSkillTarget(BattleCharacter character, MapPosition target)
 {
     this.ShowSelectedSkillTarget(character, false);
     character.SkillTargetPosition = target;
     this.ShowSelectedSkillTarget(character, true);
 }
Пример #40
0
 private void CreateBattleGrid(int numberOfRows, int numberOfColumns, Const.Team team)
 {
     for (int i = 0; i < numberOfRows; i++)
     {
         for (int j = 0; j < numberOfColumns; j++)
         {
             var mapPosition = new MapPosition(j, i, team);
             var tile = new Tile();
             this._mapTiles.Add(mapPosition, tile);
             if (this.onTileCreated != null)
             {
                 this.onTileCreated(mapPosition, tile);
             }
         }
     }
 }
Пример #41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AStarNode"/> class.
 /// </summary>
 /// <param name="_position">The position in the map this node represents</param>
 /// <param name="_f">The sum of g and the estimate to get to the goal node from this node</param>
 /// <param name="_g">The cost to get to this node from the start of the path</param>
 public AStarNode(MapPosition _position, float _f = 1.0f, float _g = 0.0f)
 {
     position = _position;
     f = _f;
     g = _g;
 }
Пример #42
0
 public int GetDistance(MapPosition otherPosition)
 {
     return this.GetXDistance(otherPosition) + this.GetYDistance(otherPosition);
 }
Пример #43
0
 private void SetTileStateAtPosition(MapPosition position, Tile.TileState state, bool flag)
 {
     if (position != null && this._mapTiles.ContainsKey(position))
     {
         this._mapTiles[position].AddOrRemoveState(state, flag);
     }
 }
Пример #44
0
    private List<MapPosition> FindPath(MapPosition start, MapPosition goal)
    {
        for (int x = 0; x < xSize; x++)
        {
            for (int y = 0; y < zSize; y++)
            {
                nodeMap[x, y].parent = null;
            }
        }

        AStarNode startNode = nodeMap[start.xPos, start.yPos];
        startNode.g = 0;
        startNode.f = startNode.g + MapPosition.EucludianDistance(start, goal);
        open.Add(startNode);

        while (open.Count > 0)
        {
            AStarNode currentNode = open[0];

            if (currentNode.position == goal)
            {
                path = new List<MapPosition>();

                int count = 0;

                while (currentNode.parent != null)
                {
                    count++;
                    path.Add(currentNode.position);
                    currentNode = nodeMap[currentNode.parent.xPos, currentNode.parent.yPos];
                    if (count > xSize * zSize * 6)
                    {
                        Debug.LogError("out of range");
                        break;
                    }
                }
                path.Add(start);
                return path;
            }

            open.RemoveAt(0);
            closed.Add(currentNode);

            List<AStarNode> neighbours = GetNeighbours(currentNode.position);

            foreach (AStarNode neighbour in neighbours)
            {
                if (closed.Contains(neighbour))
                {
                    continue;
                }

                float g = currentNode.g + neighbour.f;

                bool inOpenList = open.Contains(neighbour);
                if (!inOpenList || g < neighbour.g)
                {
                    neighbour.parent = currentNode.position;
                    neighbour.g = g;
                    neighbour.f = g + MapPosition.EucludianDistance(neighbour.position, goal);

                    if (!inOpenList)
                    {
                        int index = 0;
                        while (index < open.Count && open[index].f < neighbour.f)
                        {
                            index++;
                        }
                        open.Insert(index, neighbour);
                    }
                }
            }
        }

        return null;
    }
Пример #45
0
 public void TestY()
 {
     var position = new MapPosition(0, 8);
     Assert.AreEqual(8, position.Y);
 }
Пример #46
0
 private void MoveTerrainInDirection(MapPosition direction, LatLong location, double elevation)
 {
     if ((direction & MapPosition.Up) == MapPosition.Up)
     {
         UpdateAllTerrainAtElevation(location,elevation);
     }
     else if ((direction & MapPosition.Down) == MapPosition.Down)
     {
         UpdateAllTerrainAtElevation(location,elevation);
     }
     else if(!pauseUpdates)
     {
         if ((direction & MapPosition.N) == MapPosition.N)
         {
             for (int col = 0; col < TILE_COUNT; col++)
             {
                 LatLong locationOffset = new LatLong(TILE_COUNT * currentDelta, 0);
                 LatLong newLocation = LatLong.Add(currentTiles[TILE_COUNT - 1, col].BottomLeftLocation, locationOffset);
                 CombinedMapData newTile = SwapTileToNewLocation(currentTiles[TILE_COUNT - 1, col], newLocation);
                 for (int row = TILE_COUNT - 1; row > 0; row--)
                 {
                     currentTiles[row, col] = currentTiles[row - 1, col];
                 }
                 currentTiles[0, col] = newTile;
             }
         }
         if ((direction & MapPosition.S) == MapPosition.S)
         {
             for (int col = 0; col < TILE_COUNT; col++)
             {
                 LatLong locationOffset = new LatLong(-TILE_COUNT * currentDelta, 0);
                 LatLong newLocation = LatLong.Add(currentTiles[0, col].BottomLeftLocation, locationOffset);
                 CombinedMapData newTile = SwapTileToNewLocation(currentTiles[0, col], newLocation);
                 for (int row = 0; row < TILE_COUNT - 1; row++)
                 {
                     currentTiles[row, col] = currentTiles[row + 1, col];
                 }
                 currentTiles[TILE_COUNT - 1, col] = newTile;
             }
         }
         if ((direction & MapPosition.W) == MapPosition.W)
         {
             for (int row = 0; row < TILE_COUNT; row++)
             {
                 LatLong locationOffset = new LatLong(0, -TILE_COUNT * currentDelta);
                 LatLong newLocation = LatLong.Add(currentTiles[row, 0].BottomLeftLocation, locationOffset);
                 CombinedMapData newTile = SwapTileToNewLocation(currentTiles[row, 0], newLocation);
                 for (int col = 0; col < TILE_COUNT - 1; col++)
                 {
                     currentTiles[row, col] = currentTiles[row, col + 1];
                 }
                 currentTiles[row, TILE_COUNT - 1] = newTile;
             }
         }
         if ((direction & MapPosition.E) == MapPosition.E)
         {
             for (int row = 0; row < TILE_COUNT; row++)
             {
                 LatLong locationOffset = new LatLong(0, TILE_COUNT * currentDelta);
                 LatLong newLocation = LatLong.Add(currentTiles[row, TILE_COUNT - 1].BottomLeftLocation, locationOffset);
                 CombinedMapData newTile = SwapTileToNewLocation(currentTiles[row, TILE_COUNT - 1], newLocation);
                 for (int col = TILE_COUNT - 1; col > 0; col--)
                 {
                     currentTiles[row, col] = currentTiles[row, col - 1];
                 }
                 currentTiles[row, 0] = newTile;
             }
         }
     }
 }
Пример #47
0
 public int GetYDistance(MapPosition otherPosition)
 {
     return Math.Abs(this.Y - otherPosition.Y);
 }
Пример #48
0
 public TileController GetTileAtMapPosition(MapPosition mapPosition)
 {
     return this._mapTiles[mapPosition];
 }
Пример #49
0
 public void BindTileController(MapPosition mapPosition, Tile tile)
 {
     var controller = this._mapTiles[mapPosition];
     tile.onStateChange += controller.OnTileStateChange;
 }
Пример #50
0
 public BattleCharacter GetCharacterAtPosition(MapPosition position)
 {
     return ServiceFactory.GetBattleService().GetCharacterAtPosition(this._battleCharacters, position);
 }
Пример #51
0
 public void TestToString()
 {
     var position = new MapPosition(8, 3);
     Assert.AreEqual("8, 3", position.ToString());
 }
Пример #52
0
 public static float EucludianDistance(MapPosition _start, MapPosition _goal)
 {
     return Mathf.Sqrt(Mathf.Pow(_goal.xPos - _start.xPos, 2) + Mathf.Pow(_goal.yPos - _start.yPos, 2));
 }
Пример #53
0
 public void TestX()
 {
     var position = new MapPosition(5, 0);
     Assert.AreEqual(5, position.X);
 }
Пример #54
0
        private List<Vector2> getUpgradeSpawns(MapPosition[] powerupsSpec)
        {
            List<Vector2> spawnPoints = new List<Vector2>();

            for (int z = 0; z < powerupsSpec.Length; z++)
            {
                spawnPoints.Add(new Vector2(
                    Convert.ToInt32(powerupsSpec[z].X),
                    Convert.ToInt32(powerupsSpec[z].Y)));
            }

            return spawnPoints;
        }
Пример #55
0
 /// <summary>
 /// �w�肵�����W�̃}�b�v�`�b�v��擾����B
 /// ���݂��Ȃ��ꍇnull��Ԃ�
 /// </summary>
 /// <param name="pos"></param>
 /// <returns></returns>
 public MapChip GetMapChip(MapPosition pos)
 {
     return mapchips[pos.X, pos.Y];
 }
Пример #56
0
        private void TestMoveDirectionWithTwoObjects(
            MapPosition movablePosition,
            MapPosition staticPosition,
            PositionChange direction,
            MapPosition positionAfterMove)
        {
            var map = new Map();
            var staticObject = new MapObject { Position = staticPosition };
            var moveableObject = new MapObject { Position = movablePosition };
            map.AddObject(staticObject);
            map.AddObject(moveableObject);

            map.Move(moveableObject, direction);
            Assert.AreEqual(positionAfterMove, moveableObject.Position);
        }
Пример #57
0
 public Spawn(MapPosition position, Character character)
 {
     Position = position;
     Character = character;
 }
Пример #58
0
 public abstract MapPosition getNewPosition(MapPosition position, State state, RouteOption routeOption);
Пример #59
0
 public List<MapPosition> GetMapPositionsForPattern(Pattern pattern, Const.SkillTargetGroup targetGroup, Const.Team sourceTeam, MapPosition basePosition)
 {
     return ServiceFactory.GetMapService().GeMapPositionsForPattern(pattern, targetGroup, sourceTeam, this._mapTiles, basePosition);
 }
Пример #60
0
    public List<AStarNode> GetNeighbours(MapPosition current)
    {
        List<AStarNode> neighbours = new List<AStarNode>();

        if (current.yPos > 0 && map[current.xPos, current.yPos-1] == FLOOR && !closed.Contains(nodeMap[current.xPos, current.yPos - 1]))
        {
            neighbours.Add(nodeMap[current.xPos, current.yPos - 1]);
        }

        if (current.yPos < zSize - 1 && map[current.xPos, current.yPos + 1] == FLOOR && !closed.Contains(nodeMap[current.xPos, current.yPos + 1]))
        {
            neighbours.Add(nodeMap[current.xPos, current.yPos + 1]);
        }

        if (current.xPos > 0 && map[current.xPos - 1, current.yPos] == FLOOR && !closed.Contains(nodeMap[current.xPos - 1, current.yPos]))
        {
            neighbours.Add(nodeMap[current.xPos - 1, current.yPos]);
        }

        if (current.xPos < xSize - 1 && map[current.xPos + 1, current.yPos] == FLOOR && !closed.Contains(nodeMap[current.xPos + 1, current.yPos]))
        {
            neighbours.Add(nodeMap[current.xPos + 1, current.yPos]);
        }

        return neighbours;
    }