Ejemplo n.º 1
0
        protected void Spawn(Point3D p, Map map, BaseCreature spawn)
        {
            if (map == null)
            {
                spawn.Delete();
                return;
            }

            int x = p.X, y = p.Y;

            for (int j = 0; j < 20; ++j)
            {
                int tx = p.X - 2 + Utility.Random(5);
                int ty = p.Y - 2 + Utility.Random(5);

                LandTile t = map.Tiles.GetLandTile(tx, ty);

                if (t.Z == p.Z && ((t.ID >= 0xA8 && t.ID <= 0xAB) || (t.ID >= 0x136 && t.ID <= 0x137)) && !Spells.SpellHelper.CheckMulti(new Point3D(tx, ty, p.Z), map))
                {
                    x = tx;
                    y = ty;
                    break;
                }
            }

            spawn.MoveToWorld(new Point3D(x, y, p.Z), map);
        }
Ejemplo n.º 2
0
        public virtual void DestroyCarpet()
        {
            OnDestroy();

            if (Owner != null)
            {
                Owner.CloseGump(typeof(FlyingCarpetControlGump));

                if (Contains(Owner))
                {
                    int          z     = Map.GetAverageZ(Owner.X, Owner.Y);
                    LandTile     t     = Map.Tiles.GetLandTile(Owner.X, Owner.Y);
                    StaticTile[] tiles = Map.Tiles.GetStaticTiles(Owner.X, Owner.Y);

                    if (t.Z > z)
                    {
                        z = t.Z;
                    }

                    for (int i = 0; i < tiles.Length; i++)
                    {
                        if (tiles[i].Z > z)
                        {
                            z = tiles[i].Z;
                        }
                    }

                    Owner.Z = z;
                }
            }

            Delete();
        }
Ejemplo n.º 3
0
        protected void Spawn(Point3D p, Map map, BaseCreature spawn)
        {
            if (map == null)
            {
                spawn.Delete();
                return;
            }

            int x = p.X, y = p.Y;

            for (int j = 0; j < 20; ++j)
            {
                int tx = p.X - 2 + Utility.Random(5);
                int ty = p.Y - 2 + Utility.Random(5);

                LandTile t = map.Tiles.GetLandTile(tx, ty);

                if (t.Z == p.Z && (t.ID >= 0xA8 && t.ID <= 0xAB || t.ID >= 0x136 && t.ID <= 0x137) && !Spells.SpellHelper.CheckMulti(new Point3D(tx, ty, p.Z), map))
                {
                    x = tx;
                    y = ty;
                    break;
                }
            }

            spawn.MoveToWorld(new Point3D(x, y, p.Z), map);

            if (spawn is Kraken && 0.2 > Utility.RandomDouble())
            {
                spawn.PackItem(new MessageInABottle(Map.Felucca));
            }
        }
Ejemplo n.º 4
0
        public static bool IsValidWater(Map map, int x, int y, int z)
        {
            if (!Region.Find(new Point3D(x, y, z), map).AllowSpawn() || !map.CanFit(x, y, z, 16, false, true, false))
            {
                return(false);
            }

            LandTile landTile = map.Tiles.GetLandTile(x, y);

            if (landTile.Z == z && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Wet) != 0)
            {
                return(true);
            }

            StaticTile[] staticTiles = map.Tiles.GetStaticTiles(x, y, true);

            for (int i = 0; i < staticTiles.Length; ++i)
            {
                StaticTile staticTile = staticTiles[i];

                if (staticTile.Z == z && (TileData.ItemTable[staticTile.ID & TileData.MaxItemValue].Flags & TileFlag.Wet) != 0)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
        protected void Spawn(Point3D p, Map map, BaseCreature spawn, int onBoat)
        {
            if (map == null)
            {
                spawn.Delete();
                return;
            }

            int x = p.X, y = p.Y;

            if (onBoat != 1)
            {
                for (int j = 0; j < 20; ++j)
                {
                    int tx = p.X - 2 + Utility.Random(5);
                    int ty = p.Y - 2 + Utility.Random(5);

                    LandTile t = map.Tiles.GetLandTile(tx, ty);

                    if (t.Z == p.Z && Server.Misc.Worlds.IsWaterTile(t.ID, 0) && !Spells.SpellHelper.CheckMulti(new Point3D(tx, ty, p.Z), map))
                    {
                        x = tx;
                        y = ty;
                        break;
                    }
                }
            }
            spawn.MoveToWorld(new Point3D(x, y, p.Z), map);
        }
Ejemplo n.º 6
0
        public override bool Give(Mobile from, Item item, bool placeAtFeet)
        {
            if (item is TreasureMap || item is MessageInABottle || item is SpecialFishingNet)
            {
                BaseCreature serp;

                if (0.25 > Utility.RandomDouble())
                {
                    serp = new DeepSeaSerpent();
                }

                else
                {
                    serp = new SeaSerpent();
                }

                serp.m_WasFishedUp = true;

                int x = from.X, y = from.Y;

                Map map = from.Map;

                for (int i = 0; map != null && i < 20; ++i)
                {
                    int tx = from.X - 10 + Utility.Random(21);
                    int ty = from.Y - 10 + Utility.Random(21);

                    LandTile t = map.Tiles.GetLandTile(tx, ty);

                    if (t.Z == -5 && ((t.ID >= 0xA8 && t.ID <= 0xAB) || (t.ID >= 0x136 && t.ID <= 0x137)) && !Spells.SpellHelper.CheckMulti(new Point3D(tx, ty, -5), map))
                    {
                        x = tx;
                        y = ty;

                        break;
                    }
                }

                serp.MoveToWorld(new Point3D(x, y, -5), map);

                serp.Home      = serp.Location;
                serp.RangeHome = 10;

                //TEST: FIX
                //serp.PackItem(item);

                from.SendLocalizedMessage(503170); // Uh oh! That doesn't look like a fish!

                return(true);
            }

            if (item is WoodenChest || item is MetalGoldenChest)
            {
                placeAtFeet = true;
            }

            from.PlaySound(0x025);

            return(base.Give(from, item, placeAtFeet));
        }
Ejemplo n.º 7
0
    private void Setup()
    {
        targettedTile = LandTileMap.instance.GetLandTile(xPosition, yPosition);
        CursorMovement(true);

        CameraManager.instance.FollowObject(this.transform);            // TEMPORARY THIS IS JUST HERE TO START THE SCENE CORRECTLY BEFORE PROPER START IS IMPLEMENTED
    }
Ejemplo n.º 8
0
    public void MoveUnitToTile(Unit unit, int x, int y)
    {
        unit.currentTile.unitOnTile = null;
        LandTile tile = GetLandTile(x, y);

        tile.unitOnTile  = unit;
        unit.currentTile = tile;
    }
Ejemplo n.º 9
0
    public void MoveUnitToTile(Unit unit, Vector3 newPosition)
    {
        unit.currentTile.unitOnTile = null;
        LandTile tile = GetTileByWorldPoint(newPosition);

        tile.unitOnTile  = unit;
        unit.currentTile = tile;
    }
Ejemplo n.º 10
0
 public CombatAction(Unit unit, LandTile tileToTarget, Ability abilityToCast, int requiredTurnTimer)
 {
     this.unit          = unit;
     this.targettedTile = tileToTarget;
     this.abilityToCast = abilityToCast;
     this.requiredTimer = requiredTurnTimer;
     this.turnTimer     = 0;
 }
Ejemplo n.º 11
0
    ///<summary>
    /// Adds a CombatAction to the turn order
    ///</summary>
    public void AddCombatAction(Unit unit, LandTile tileToTarget, Ability abilityToCast, int requiredTurnTimer)
    {
        CombatAction t = new CombatAction(unit, tileToTarget, abilityToCast, requiredTurnTimer);

        turnOrder.Add(t);

        turnOrder = turnOrder.OrderByDescending(Turn => Turn.turnTimer).ToList();
    }
Ejemplo n.º 12
0
 public override bool Condition(LandTile landTile)
 {
     if (landTile.Owned)
     {
         TileManager.instance.BuildMenu.UpdateButtonsForSelectedTile(landTile);
     }
     return(landTile.Owned);
 }
Ejemplo n.º 13
0
    ///<summary>
    /// Called to show the cursor on the grid; without a movement/ability selection
    ///</summary>
    public void SetupSelectionCursor(int xPosition, int yPosition)
    {
        isSelecting             = false;
        this.xPosition          = xPosition; this.yPosition = yPosition;
        this.transform.position = new Vector3(xPosition, targettedTile.tileHeight - 0.4f, yPosition);

        targettedTile = LandTileMap.instance.GetLandTile(xPosition, yPosition);
    }
Ejemplo n.º 14
0
    // Use this for initialization
    void Start()
    {
        renderer = GetComponent <SpriteRenderer>();
        animator = GetComponent <Animator>();
        tile     = transform.parent.GetComponent <LandTile>();

        transform.rotation = Quaternion.identity;
        transform.position = (Vector2)tile.transform.position;
    }
Ejemplo n.º 15
0
 void Purchase(LandTile Current)
 {
     Current.owner = AIpla;
     EnemyTurn     = false;
     Current.GetComponent <LandTile>().hire1 = AIpla;
     Current.GetComponent <LandTile>().hire3 = AIpla;
     Tiles++;
     Current.GetComponent <SpriteRenderer>().sprite = AISprite;
 }
Ejemplo n.º 16
0
 public override bool Trigger(LandTile landTile)
 {
     if (TileManager.instance)
     {
         TileManager.instance.BuildMenu.BuildingButtonsContainer.SetActive(true);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 17
0
        public static void ShowBlockingTiles(Mobile from, List <Point2D> blockedPoints, List <Point2D> yardPoints, Map map)
        {
            if (from == null)
            {
                return;
            }

            from.SendSound(0x64B);

            int blockedPointsCount = blockedPoints.Count;

            if (blockedPointsCount > 100)
            {
                blockedPointsCount = 100;
            }

            for (int a = 0; a < blockedPointsCount; a++)
            {
                Point3D location;
                Point2D point = blockedPoints[a];

                BlockedHousingTimedStatic blockedLocation = new BlockedHousingTimedStatic(0x3709, 3);
                blockedLocation.Name    = "blocked housing tile";
                blockedLocation.Hue     = 2953;
                blockedLocation.m_Owner = from;

                LandTile landTile = map.Tiles.GetLandTile(point.X, point.Y);

                location = new Point3D(point.X, point.Y, landTile.Z);

                blockedLocation.MoveToWorld(location, map);
            }

            int blockedYardCount = yardPoints.Count;

            if (blockedYardCount > 100)
            {
                blockedYardCount = 100;
            }

            for (int a = 0; a < blockedYardCount; a++)
            {
                Point3D location;
                Point2D point = yardPoints[a];

                BlockedHousingTimedStatic blockedLocation = new BlockedHousingTimedStatic(0x3709, 3);
                blockedLocation.Name    = "blocked housing tile";
                blockedLocation.Hue     = 2579;
                blockedLocation.m_Owner = from;

                LandTile landTile = map.Tiles.GetLandTile(point.X, point.Y);

                location = new Point3D(point.X, point.Y, landTile.Z);

                blockedLocation.MoveToWorld(location, map);
            }
        }
Ejemplo n.º 18
0
    // Update is called once per frame
    void Update()
    {
        Touch[] touches = Controls.GetTouchesAndMouse();

        if (!IsCountingDown)
        {
            foreach (Touch touch in touches)
            {
                Vector2 touchPos = Camera.main.ScreenToWorldPoint(touch.position);

                // check for click
                if (touch.phase == TouchPhase.Began && collider.OverlapPoint(touchPos))
                {
                    Controls.mode = Controls.Mode.pulling;
                }

                if (Controls.mode == Controls.Mode.pulling)
                {
                    if (touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary)
                    {
                        // Drag
                        transform.position = touchPos;
                    }
                    else if (touch.phase == TouchPhase.Ended)
                    {
                        LandTile tile = Controls.GetComponentAtPos <LandTile>(transform.position, "Tile");

                        // a bunny obsructs your path!
                        Bunny bunny = Controls.GetComponentAtPos <Bunny>(transform.position, "Bunny");

                        if (tile != null && bunny == null && tile.watered && tile.status == LandTile.Status.ready)
                        {
                            transform.position = (Vector2)tile.transform.position;
                            tile.status        = LandTile.Status.pulling;

                            StartCoroutine(StartCountdown());
                        }
                    }
                }
            }

            if (touches.Length <= 0)
            {
                // Drop with Lerp
                if (Vector2.Distance(transform.position, init_position) < 2f)
                {
                    transform.position = init_position;
                    Controls.mode      = Controls.Mode.gathering_seeds;
                }
                else
                {
                    transform.position = Vector2.Lerp(transform.position, init_position, 9 * Time.deltaTime);
                }
            }
        }
    }
Ejemplo n.º 19
0
    ///<summary>
    /// Activates the Grid Cursor
    ///</summary>
    public void ActivateGridCursor(Vector3 startPosition, Action <Transform> OnConfirmationEvent, Action <bool> OnCancelationEvent)
    {
        GameManager.instance.SetModeInputCursor();
        gridCursor.gameObject.SetActive(true);

        LandTile tile = GetTileByWorldPoint(startPosition);

        gridCursor.SetupSelectionCursor(tile.positionX, tile.positionY, OnConfirmationEvent, OnCancelationEvent);
        CameraManager.instance.FollowObject(gridCursor.transform);
    }
Ejemplo n.º 20
0
    public override bool Trigger(LandTile landTile)
    {
        LandTile neighbor;

        //Tile Above
        if (TileManager.instance.TryGetActiveTile((int)landTile.transform.position.x, (int)landTile.transform.position.y + 10, out neighbor))
        {
            if (neighbor.walls[2] == null)
            {
                Wall newWall = Instantiate(BasicWall,
                                           new Vector3Int((int)(landTile.transform.position.x), 1, (int)(landTile.transform.position.y + 5)),
                                           Quaternion.identity,
                                           CityManager.instance.transform);
                neighbor.walls[2] = newWall;
                landTile.walls[0] = newWall;
            }
        }
        if (TileManager.instance.TryGetActiveTile((int)landTile.transform.position.x + 10, (int)landTile.transform.position.y, out neighbor))
        {
            if (neighbor.walls[3] == null)
            {
                Wall newWall = Instantiate(BasicWall,
                                           new Vector3Int((int)(landTile.transform.position.x + 5), 1, (int)(landTile.transform.position.y)),
                                           Quaternion.identity,
                                           CityManager.instance.transform);
                neighbor.walls[3] = newWall;
                landTile.walls[1] = newWall;
            }
        }
        if (TileManager.instance.TryGetActiveTile((int)landTile.transform.position.x, (int)landTile.transform.position.y - 10, out neighbor))
        {
            if (neighbor.walls[0] == null)
            {
                Wall newWall = Instantiate(BasicWall,
                                           new Vector3Int((int)(landTile.transform.position.x), 1, (int)(landTile.transform.position.y - 5)),
                                           Quaternion.identity,
                                           CityManager.instance.transform);
                neighbor.walls[0] = newWall;
                landTile.walls[2] = newWall;
            }
        }
        if (TileManager.instance.TryGetActiveTile((int)landTile.transform.position.x - 10, (int)landTile.transform.position.y, out neighbor))
        {
            if (neighbor.walls[1] == null)
            {
                Wall newWall = Instantiate(BasicWall,
                                           new Vector3Int((int)(landTile.transform.position.x - 5), 1, (int)(landTile.transform.position.y)),
                                           Quaternion.identity,
                                           CityManager.instance.transform);
                neighbor.walls[1] = newWall;
                landTile.walls[3] = newWall;
            }
        }
        return(landTile.Owned = true);
    }
Ejemplo n.º 21
0
        public override bool Give(Mobile m, Item item, bool placeAtFeet)
        {
            if (item is TreasureMap || item is MessageInABottle || item is SpecialFishingNet)
            {
                BaseCreature serp;

                if (0.25 > Utility.RandomDouble())
                {
                    serp = new DeepSeaSerpent();
                }
                else
                {
                    serp = new SeaSerpent();
                }

                int x = m.X, y = m.Y;

                Map map = m.Map;

                for (int i = 0; map != null && i < 20; ++i)
                {
                    int tx = m.X - 10 + Utility.Random(21);
                    int ty = m.Y - 10 + Utility.Random(21);

                    LandTile t = map.Tiles.GetLandTile(tx, ty);

                    if (t.Z == -5 && (t.ID >= 0xA8 && t.ID <= 0xAB || t.ID >= 0x136 && t.ID <= 0x137) &&
                        new Point3D(tx, ty, -5).GetMulti(map) == null
                        )
                    {
                        x = tx;
                        y = ty;
                        break;
                    }
                }

                serp.MoveToWorld(new Point3D(x, y, -5), map);

                serp.Home      = serp.Location;
                serp.RangeHome = 10;

                serp.PackItem(item);

                m.SendLocalizedMessage(503170); // Uh oh! That doesn't look like a fish!

                return(true);                   // we don't want to give the item to the player, it's on the serpent
            }

            if (item is BigFish || item is WoodenChest || item is MetalGoldenChest)
            {
                placeAtFeet = true;
            }

            return(base.Give(m, item, placeAtFeet));
        }
Ejemplo n.º 22
0
    public static float GetDistance(LandTile a, LandTile b)
    {
        float distX = Mathf.Abs(a.transform.position.x - b.transform.position.y);
        float distZ = Mathf.Abs(a.transform.position.z - b.transform.position.z);

        if (distX > distZ)
        {
            return(14 * distZ + 10 * distX);
        }
        return(14 * distX + 10 * distZ);
    }
Ejemplo n.º 23
0
    ///<summary>
    /// Called to show the cursor on the grid; with movement/ability selection
    ///</summary>
    public void SetupSelectionCursor(int xPosition, int yPosition, Action <Transform> OnConfirmationEvent, Action <bool> OnCancelationEvent)
    {
        isSelecting             = true;
        this.xPosition          = xPosition; this.yPosition = yPosition;
        this.transform.position = new Vector3(xPosition, targettedTile.tileHeight - 0.4f, yPosition);

        this.OnConfirmationAction = OnConfirmationEvent;
        OnCancelationAction       = OnCancelationEvent;

        targettedTile = LandTileMap.instance.GetLandTile(xPosition, yPosition);
    }
Ejemplo n.º 24
0
        public static void CheckLandTile(BaseCreature fbc)
        {
            if (NullCheck(fbc))
            {
                return;
            }

            LandTile landTile = fbc.Map.Tiles.GetLandTile(fbc.X, fbc.Y);

            fbc.Ground = landTile.Z;
        }
Ejemplo n.º 25
0
        public bool IsGuarded(int facet, int x, int y)
        {
            LandTile landTile = this.land[Viewport.GetSlot(x, y)];

            if (landTile != null && landTile.x == x && (landTile.y == y && landTile.facet == facet))
            {
                return(landTile.m_Guarded);
            }
            int averageZ = Map.GetAverageZ(x, y);

            return(Region.Find(Region.GuardedRegions, x, y, averageZ, facet) != null);
        }
Ejemplo n.º 26
0
    //=================================================================
    //             SpawnFarm(GameObject tile)
    //=================================================================
    private void SpawnFarm(LandTile tile)
    {
        float xPos = tile.transform.position.x;
        float zPos = tile.transform.position.z;

        GameObject tempBuilding = Instantiate(farmPrefab, new Vector3(xPos, yOffsetHouse, zPos), Quaternion.identity);

        tile.Building = tempBuilding;
        tempBuilding.GetComponentInParent <Building>().Tile = tile.gameObject;
        townHall.FarmAmount++;
        tile.OnBuildingPlaced();
    }
Ejemplo n.º 27
0
    public AIAttackAction(OtherUnit targetUnit, int score, LandTile tileToMoveTo = null)
    {
        this.targetUnit = targetUnit;
        this.score      = score;

        if (tileToMoveTo == null)
        {
            return;
        }
        this.tileToMoveTo = tileToMoveTo;
        requiresMovement  = true;
    }
Ejemplo n.º 28
0
        protected override unsafe void UpdateMesh(LandTile tile, int baseColor)
        {
            fixed(TransformedColoredTextured *transformedColoredTexturedPtr = this._mesh)
            {
                int quadColor = Renderer.GetQuadColor(baseColor);

                transformedColoredTexturedPtr->Color   = quadColor;
                transformedColoredTexturedPtr[1].Color = quadColor;
                transformedColoredTexturedPtr[2].Color = quadColor;
                transformedColoredTexturedPtr[3].Color = quadColor;
            }
        }
Ejemplo n.º 29
0
        // Tass23 Tree Tile Check
        private bool IsTreeTiles(int X, int Y, Map map)
        {
            LandTile list = map.Tiles.GetLandTile(X, Y);

            for (int l = 0; l < m_TreeTiles.Length; l++)
            {
                if (m_TreeTiles[l] == list.ID)
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 30
0
        // Tass23 Mining Tile Check
        private bool IsMiningTile(int X, int Y, Map map)
        {
            LandTile list = map.Tiles.GetLandTile(X, Y);

            for (int l = 0; l < m_MountainAndCaveTiles.Length; l++)
            {
                if (m_MountainAndCaveTiles[l] == list.ID)
                {
                    return(true);
                }
            }
            return(false);
        }