Exemple #1
0
        bool F402_xxxx_MENUS_IsMeleeActionPerformed(MapDirection direction)
        {
            var enemy = GetAccesibleEnemies(direction); //aka ismeleeActionPerformed
            if (enemy != null)
            {

                if (false) //TODO (P775_i_ActionIndex == C024_ACTION_DISRUPT) && !M07_GET(F144_amzz_DUNGEON_GetCreatureAttributes(G517_T_ActionTargetGroupThing), MASK0x0040_NON_MATERIAL))
                {
                }
                else
                {
                    ActionProbabilityInfo A1237_i_ActionHitProbability = new ActionProbabilityInfo(factory.HitProbability); //G493_auc_Graphic560_ActionHitProbability[P775_i_ActionIndex];
                    int A1236_ui_ActionDamageFactor = factory.Damage;  //G492_auc_Graphic560_ActionDamageFactor[P775_i_ActionIndex];
                    A1237_i_ActionHitProbability.HitNonmaterial = attackProvider.GetProperty(PropertyFactory<NonMaterialProperty>.Instance).MaxValue > 0;
                    //if ((F033_aaaz_OBJECT_GetIconIndex(P774_ps_Champion->Slots[C01_SLOT_ACTION_HAND]) == C040_ICON_WEAPON_VORPAL_BLADE) || (P775_i_ActionIndex == C024_ACTION_DISRUPT))
                    //{
                    //    M08_SET(A1237_i_ActionHitProbability, MASK0x8000_HIT_NON_MATERIAL_CREATURES);
                    //}
                    F231_izzz_GROUP_GetMeleeActionDamage(enemy, A1237_i_ActionHitProbability, A1236_ui_ActionDamageFactor/*, P778_i_SkillIndex*/);
                    return true;
                }
            }
            T402_010:
            return false;
        }
Exemple #2
0
        public async void ApplyAttack(MapDirection direction)
        {
            var fatigue = factory.Fatigue;
            var requiredSkill = attackProvider.GetSkill(factory.SkillIndex);
            var requiredStamina = factory.Stamina + rand.Next(2);

            if (F402_xxxx_MENUS_IsMeleeActionPerformed(direction))
            {
                fatigue >>= 1;
            }

            //AfterSwitch
            if (fatigue > 0)
            {
                await Task.Delay(fatigue);
            }
            if (requiredStamina > 0)
            {
                attackProvider.GetProperty(PropertyFactory<StaminaProperty>.Instance).Value -= requiredStamina;
            }
            if (factory.ExperienceGain > 0)
            {
                requiredSkill.AddExperience(factory.ExperienceGain);
            }
        }
 /// <summary>
 /// Состояние стены
 /// </summary>
 /// <param name="Wall">Стена</param>
 /// <param name="Direction">Направление стены в клетке</param>
 public MapWallState(MapWall Wall, MapDirection Direction)
     : base(Wall)
 {
     this._Health = Wall.Health;
     this.Mode = Wall.Mode;
     this.Direction = Direction;
 }
Exemple #4
0
    public bool HasDirectionPos(MapDirection mapDir, Coord co)
    {
        int posX;
        int posY;

        GetDirectionPos(out posX, out posY, co, mapDir);
        return(posX >= 0 && posX < MapWidth && posY >= 0 && posY < MapHeight);
    }
Exemple #5
0
 /// <see cref="IMissileData.GetRelativeLaunchPosition"/>
 public RCNumVector GetRelativeLaunchPosition(MapDirection direction)
 {
     if (!this.relativeLaunchPositions.ContainsKey(direction))
     {
         throw new SimulatorException(string.Format("Relative launch position for map direction '{0}' is not defined!", direction));
     }
     return(this.relativeLaunchPositions[direction]);
 }
Exemple #6
0
    public Coord GetDirectionCoord(MapDirection mapDir, Coord co)
    {
        int posX;
        int posY;

        GetDirectionPos(out posX, out posY, co, mapDir);
        return(new Coord((uint)posX, (uint)posY));
    }
Exemple #7
0
 /// <summary>
 /// Стена
 /// </summary>
 /// <param name="ImageWall">Картинка в закрытом состоянии</param>
 /// <param name="Health">Здовровье стены</param>
 /// <param name="Mode">Режим стены</param>
 public MapWall(MapImage ImageWall, MapDirection BaseDirection, UInt16 Health)
     : base(new MapTile(ImageWall, new MapSize(1, 1)))
 {
     this.ImageWindow = ImageWindow;
     this.ImageDoor   = ImageDoor;
     this.Health      = Health;
     this.ArmorType   = MapArmorType.Building;
     this.Mode        = MapWallMode.Wall;
 }
 public ConventionalMapAttribute([NotNull] Type entityType, MapDirection direction = MapDirection.Both)
 {
     if (entityType == null)
     {
         throw new ArgumentNullException(nameof(entityType));
     }
     Direction  = direction;
     EntityType = entityType;
 }
Exemple #9
0
 /// <summary>
 /// Состояние активного объекта карты
 /// </summary>
 /// <param name="ActiveObject">Активный объект</param>
 /// <param name="Position">Координаты левой верхней точки</param>
 public MapActiveObjectState(MapActiveObject ActiveObject, MapPoint Position)
     : base(ActiveObject)
 {
     this.Position   = Position;
     this.ArmorType  = ActiveObject.ArmorType;
     this._Health    = ActiveObject.Health;
     this._Direction = Direction;
     this.ActualSize = this.Size;
 }
 /// <summary>
 /// Стена
 /// </summary>        
 /// <param name="ImageWall">Картинка в закрытом состоянии</param>        
 /// <param name="Health">Здовровье стены</param>
 /// <param name="Mode">Режим стены</param>        
 public MapWall(MapImage ImageWall, MapDirection BaseDirection, UInt16 Health)
     : base(new MapTile(ImageWall, new MapSize(1, 1)))
 {
     this.ImageWindow = ImageWindow;
     this.ImageDoor = ImageDoor;
     this.Health = Health;
     this.ArmorType = MapArmorType.Building;
     this.Mode = MapWallMode.Wall;
 }
 /// <summary>
 /// Состояние активного объекта карты
 /// </summary>
 /// <param name="ActiveObject">Активный объект</param>        
 /// <param name="Position">Координаты левой верхней точки</param>
 public MapActiveObjectState(MapActiveObject ActiveObject, MapPoint Position)
     : base(ActiveObject)
 {
     this.Position = Position;
     this.ArmorType = ActiveObject.ArmorType;
     this._Health = ActiveObject.Health;
     this._Direction = Direction;
     this.ActualSize = this.Size;
 }
Exemple #12
0
    public IntVector2 GetMoveDirectionCoord(IntVector2 coord, MapDirection dir)
    {
        IntVector2 ret       = coord;
        bool       isEvenRow = (coord.y & 0x1) == 1;

        switch (dir)
        {
        case MapDirection.Left:
            ret.x -= 1;
            break;

        case MapDirection.Right:
            ret.x += 1;
            break;

        case MapDirection.LeftTop:
            ret.y += 1;
            if (isEvenRow)
            {
                ret.x -= 1;
            }
            break;

        case MapDirection.LeftBottom:
            ret.y -= 1;
            if (isEvenRow)
            {
                ret.x -= 1;
            }
            break;

        case MapDirection.RightTop:
            ret.y += 1;
            if (!isEvenRow)
            {
                ret.x += 1;
            }
            break;

        case MapDirection.RightBottom:
            ret.y -= 1;
            if (!isEvenRow)
            {
                ret.x += 1;
            }
            break;

        default:
            break;
        }
        if (!MapDataManager.Instance.IsValidTileCoord(ret.x, ret.y))
        {
            ret = MapDataManager.InValidMapCoord;
        }
        return(ret);
    }
Exemple #13
0
    //Create passage between the current cell and the neighbor
    public void CreatePassage(Cell cell, Cell otherCell, MapDirection dir)
    {
        //Instantiate the passage in the cell's position, facing the other cell
        MapFloor passage = Instantiate(passagePrefab) as MapFloor;

        passage.Initialise(cell, otherCell, dir);
        //Instantiate another passage in the other cell's position, facing the current cell
        passage = Instantiate(passagePrefab) as MapFloor;
        passage.Initialise(otherCell, cell, dir.GetOpposite());
    }
Exemple #14
0
 public Teleport(Vector3 position, int targetMapIndex, Point targetGridPosition, MapDirection direction, bool teleportOpen, bool teleportVisible, IConstrain scopeConstrain) : base(position)
 {
     InitializeGraphics();
     NextLevelIndex     = targetMapIndex;
     TargetTilePosition = targetGridPosition;
     Direction          = direction;
     ContentActivated   = teleportOpen;
     Visible            = teleportVisible;
     ScopeConstrain     = scopeConstrain;
 }
        /// <summary>
        /// Активный объект карты
        /// </summary>        
        /// <param name="Image">Картинка</param>
        /// <param name="DestroyedActiveObject">Разрушенный активный объект (если нет - null)</param>
        /// <param name="Size">Размер (в клетках карты)</param>
        /// <param name="Direction">Направление</param>
        /// <param name="ArmorType">Тип брони</param>
        /// <param name="Health">Здоровье (0...)</param>
        /// <param name="Passability">Проходимость (0..1)</param>
        public MapActiveObject(MapImage Image, MapActiveObject DestroyedActiveObject, MapSize Size, MapDirection Direction, MapArmorType ArmorType, UInt16 Health, MapPassability Passability)
            : base(new MapTile(Image, Size))
        {
            if ((Passability < 0) || (Passability > 1)) throw new ArgumentOutOfRangeException("Passability", "Passability of Place must be in range 0..1");

            this.DestroyedActiveObject = DestroyedActiveObject;
            this.BaseDirection = Direction;
            this.Health = Health;
            this.Passability = Passability;
            this.ArmorType = ArmorType;
        }
        /// <summary>
        /// Constructs a NeighbourCondition instance.
        /// </summary>
        /// <param name="combination">The terrain combination of the neighbour to check.</param>
        /// <param name="direction">The direction of the neighbour to check.</param>
        /// <param name="tileset">The tileset of this condition.</param>
        public NeighbourCondition(TerrainCombination combination, MapDirection direction, TileSet tileset)
        {
            if (tileset == null)
            {
                throw new ArgumentNullException("tileset");
            }

            this.combination = combination;
            this.direction   = direction;
            this.tileset     = tileset;
        }
Exemple #17
0
 public Vector2 GetNeighborPosition(MapDirection dir)
 {
     if (Neighbors [dir] != null)
     {
         return(new Vector2(Neighbors[dir].Position.X, Neighbors[dir].Position.Y));
     }
     else
     {
         return(Vector2.Zero);
     }
 }
Exemple #18
0
    public bool     AttackOrStalk(Transform target, bool outerCircleOK, ref MapDirection direction)
    {
        bool result = false;

        //sees if any ground targets are open
        //adds target to dictionary if available, sets direction to open spot, returns true
        //adds target to outer circle if not available, returns false
        if (!HasNorthAttacker)
        {
            NorthAttacker = target;
            direction     = MapDirection.A_North;
            result        = true;
        }
        else if (!HasEastAttacker)
        {
            EastAttacker = target;
            direction    = MapDirection.C_East;
            result       = true;
        }
        else if (!HasSouthAttacker)
        {
            SouthAttacker = target;
            direction     = MapDirection.E_South;
            result        = true;
        }
        else if (!HasWestAttacker)
        {
            WestAttacker = target;
            direction    = MapDirection.G_West;
            result       = true;
        }

        if (result)
        {
            target.parent = tr;
            if (!mGroundAttackers.Contains(target))
            {
                mGroundAttackers.Add(target);
            }
            //mGroundAttackers.Remove (target);
            mFollowers.Remove(target);
            mGroundStalkers.Remove(target);
            mCompanions.Remove(target);
        }
        else if (outerCircleOK)
        {
            direction = MapDirection.I_None;
            AddGroundStalker(target);
            result = true;
        }

        CheckTargetUpdater();
        return(result);
    }
Exemple #19
0
        public Teleport(Vector3 position, int targetMapIndex, Point targetGridPosition, MapDirection direction, bool teleportOpen, bool teleportVisible, IConstrain scopeConstrain) : base(position)
        {
            InitializeGraphics();
            NextLevelIndex = targetMapIndex;
            TargetTilePosition = targetGridPosition;
            Direction = direction;
            ContentActivated = teleportOpen;
            Visible = teleportVisible;
            ScopeConstrain = scopeConstrain;

        }
Exemple #20
0
        /// <summary>
        /// Checks and assigns the parameters coming from the constructor.
        /// </summary>
        /// <param name="targetQuarter">The target quarter of this changeset.</param>
        private void CheckAndAssignCtorParams(MapDirection targetQuarter)
        {
            if (targetQuarter != MapDirection.North &&
                targetQuarter != MapDirection.East &&
                targetQuarter != MapDirection.South &&
                targetQuarter != MapDirection.West)
            {
                throw new ArgumentException("The target quarter must be one of the followings: MapDirection.North, MapDirection.East, MapDirection.South or MapDirection.West!", "targetQuarter");
            }

            this.targetQuarter = targetQuarter;
        }
Exemple #21
0
        List <MapDirection> TunnelDirections(MapDirection lastDirection)
        {
            var copy = new List <MapDirection>(dj_dirs);
            var dirs = (List <MapDirection>)Shuffle(copy);

            if (RollPercent(opts.corridorBendChance))
            {
                dirs.Insert(0, lastDirection);
            }

            return(dirs);
        }
Exemple #22
0
        protected virtual async Task <TileSide> CreateWallSide(MapDirection wallDirection, WallTileData wall, Point pos)
        {
            ActuatorItemData[] sensorsData;
            if (wall != null)
            {
                sensorsData = wall.Actuators.Where(a => a.TilePosition == wallDirection.Opposite.ToTilePosition()).ToArray();
            }
            else
            {
                sensorsData = new ActuatorItemData[0];
            }

            TextDataItem textData = wall?.TextTags.FirstOrDefault(x => x.TilePosition == wallDirection.Opposite.ToTilePosition());

            int?randomTexture;

            if (!sensorsData.Any() && AllowedRandomDecoration(wallDirection, wall, out randomTexture))
            {
                sensorsData = new[]
                {
                    new ActuatorItemData
                    {
                        ActuatorType = 0,
                        IsLocal      = true,
                        Decoration   = randomTexture.Value + 1
                    }
                }
            }
            ;

            if (textData != null)
            {
                var res = new TextTileSide(wallDirection, textData.IsVisible, textData.Text);
                res.Renderer = builder.Factories.RenderersSource.GetTextSideRenderer(res, builder.WallTexture);
                return(res);
            }
            else if (!sensorsData.Any())
            {
                var res = new TileSide(wallDirection);
                res.Renderer = builder.Factories.RenderersSource.GetWallSideRenderer(res, builder.WallTexture);
                return(res);
            }
            else
            {
                var items = wall.GrabableItems
                            .Select(builder.ItemCreator.CreateItem)
                            .ToList();

                var res = new ActuatorWallTileSide(await wallCreator.ParseActuatorX(sensorsData, items, pos), wallDirection);
                res.Renderer = builder.Factories.RenderersSource.GetActuatorWallSideRenderer(res, builder.WallTexture);
                return(res);
            }
        }
Exemple #23
0
        /// <summary>Get cost of moving to this node from the supplied other node</summary>
        /// <typeparam name="T">Content type of other node, must derive from IMapNode</typeparam>
        /// <param name="from">Other node to move from</param>
        /// <returns>Total cost of movement, or +Infinity on invalid move</returns>
        public double CalcMoveCost <T>(PFState <T> from)
            where T : class, IMapNode, new()
        {
            if (!from.Visited)
            {
                return(double.PositiveInfinity);
            }
            MapDirection dir  = DirectionFrom(from);
            double       mult = dir.IsOrthogonal() ? 1 : 1.5;

            return(from.TotalCost + MoveCost * mult);
        }
Exemple #24
0
 public Navnode GetNextNode(int start, MapDirection dir)
 {
     try
     {
         return(navmesh[start].Neighbors[dir]);
     }
     catch
     {
         Console.WriteLine("Node " + start + " has no " + dir.ToString() + " neighbor!");
         return(null);
     }
 }
Exemple #25
0
 /// <summary>
 /// Initializes a new instance of the FileMap class
 /// </summary>
 /// <param name="files">the files that will be added to the archive file</param>
 public FileMap(string[] files)
     : this()
 {
     RootDir          = GetTopMostDirectory(files);
     direction        = MapDirection.FileToArchive;
     flattenStructure = false;
     Prepare(false);
     entries.AddRange((from t in files select new FileMapEntry(Transform(t))
     {
         LocationInFileSystem = t, Direction = direction
     }));
 }
Exemple #26
0
    //Create wall between the current cell and the other cell, called if other cell is null
    void CreateWall(Cell cell, Cell otherCell, MapDirection dir)
    {
        //Instantiate a wall on the correct side of the cell
        MapWall wall = Instantiate(wallPrefab) as MapWall;

        wall.Initialise(cell, otherCell, dir);
        //Instantiate a wall on the opposite side of the other cell if it isn't null
        if (otherCell != null)
        {
            wall = Instantiate(wallPrefab) as MapWall;
            wall.Initialise(otherCell, cell, dir.GetOpposite());
        }
    }
Exemple #27
0
        /// <summary>
        /// Loads a new frame instruction from the given XML node.
        /// </summary>
        /// <param name="instructionElem">The XML node to load from.</param>
        /// <param name="spritePalette">The sprite palette that the animation instruction is based on.</param>
        /// <returns>The constructed instruction.</returns>
        private static Animation.IInstruction LoadNewFrameInstruction(XElement instructionElem, ISpritePalette <MapDirection> spritePalette)
        {
            XAttribute spritesAttr  = instructionElem.Attribute(XmlMetadataConstants.FRAME_SPRITES_ATTR);
            XAttribute durationAttr = instructionElem.Attribute(XmlMetadataConstants.FRAME_DURATION_ATTR);

            if (spritesAttr == null)
            {
                throw new SimulatorException("Sprites not defined for new frame instruction!");
            }

            string[] spriteNames = spritesAttr.Value.Split(',');
            if (spriteNames.Length == 0)
            {
                throw new SimulatorException("Syntax error!");
            }

            Dictionary <MapDirection, int[]> spriteIndices = new Dictionary <MapDirection, int[]>
            {
                { MapDirection.North, new int[spriteNames.Length] },
                { MapDirection.NorthEast, new int[spriteNames.Length] },
                { MapDirection.East, new int[spriteNames.Length] },
                { MapDirection.SouthEast, new int[spriteNames.Length] },
                { MapDirection.South, new int[spriteNames.Length] },
                { MapDirection.SouthWest, new int[spriteNames.Length] },
                { MapDirection.West, new int[spriteNames.Length] },
                { MapDirection.NorthWest, new int[spriteNames.Length] },
            };

            /// Search the appropriate sprite indices for each directions from the sprite palette.
            foreach (KeyValuePair <MapDirection, int[]> item in spriteIndices)
            {
                MapDirection direction = item.Key;
                for (int i = 0; i < spriteNames.Length; i++)
                {
                    /// Get the sprite index for the current direction or for MapDirection.Undefined if not found.
                    int spriteIndex = spritePalette.GetSpriteIndex(spriteNames[i], direction);
                    if (spriteIndex == -1)
                    {
                        spriteIndex = spritePalette.GetSpriteIndex(spriteNames[i], MapDirection.Undefined);
                    }

                    if (spriteIndex == -1)
                    {
                        throw new SimulatorException(string.Format("Sprite '{0}' not defined for neither {1} nor {2}!", spriteNames[i], direction, MapDirection.Undefined));
                    }
                    spriteIndices[direction][i] = spriteIndex;
                }
            }

            return(new NewFrameInstruction(spriteIndices, durationAttr != null ? XmlHelper.LoadInt(durationAttr.Value) : 1));
        }
Exemple #28
0
        public MoveAction(MudCharacter character, string direction) : base(character)
        {
            Beneficial = true;
            MapDirection dir = MapDirection.north;

            for (int x = 1; x < DirectionString.Length; x++)
            {
                if (DirectionString[x] == direction)
                {
                    dir = (MapDirection)x;
                }
            }
            this.direction = dir;
        }
Exemple #29
0
        public void ModifyDirection(int change)
        {
            int dir = ((int)CurrentDirection) + change;

            if (dir < 0)
            {
                dir = 3;
            }
            else if (dir > 3)
            {
                dir = 0;
            }
            CurrentDirection = (MapDirection)dir;
        }
Exemple #30
0
    protected bool stop = false; //Should the enemy be paused


    void Start()
    {
        gameManager = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameManager>();

        //set the pos to the current cell's coords then move them to the right place
        pos = currCell.coordinates;
        transform.position      = cells[pos.x, pos.y].transform.position;
        transform.localPosition = new Vector3(transform.position.x, transform.lossyScale.y, transform.position.z);
        map          = GameObject.FindGameObjectWithTag("GameController").GetComponent <Map>();
        uiController = GameObject.FindGameObjectWithTag("GameController").GetComponent <UIController>();
        //Set parent to the current cell
        transform.parent = currCell.transform;
        dir = MapDirection.North;
    }
Exemple #31
0
        void CreateTunnel(int i, int j, MapDirection last_dir)
        {
            var dirs = TunnelDirections(last_dir);

            foreach (MapDirection dir in dirs)
            {
                if (OpenTunnel(i, j, dir))
                {
                    var next_i = i + di[dir];
                    var next_j = j + dj[dir];

                    CreateTunnel(next_i, next_j, last_dir);
                }
            }
        }
Exemple #32
0
 //Check if there is a wall in front of the pawn
 protected bool CheckForWall()
 {
     foreach (Transform t in currCell.transform)
     {
         if (t.tag == "Wall")
         {
             MapDirection wallDir = t.GetComponent <MapCellEdge>().dir;
             if (dir == wallDir)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #33
0
        protected override void OnMapDirectionChanged(MapDirection oldDirection, MapDirection newDirection)
        {
            base.OnMapDirectionChanged(oldDirection, newDirection);
            $"Direction changed: {oldDirection} -> {newDirection}".Dump();

            if (oldDirection != newDirection.Opposite)
            {
                RotateParty(oldDirection, newDirection);
            }
            else
            {
                var midle = oldDirection.NextClockWise;
                RotateParty(oldDirection, midle);
                RotateParty(midle, newDirection);
            }
        }
        private void SetMapDirection(MapDirection value, bool setForwardDirection)
        {
            var oldDirection = mapDirection;

            if (mapDirection != value)
            {
                mapDirection = value;

                if (setForwardDirection)
                {
                    ForwardDirection = new Vector3(mapDirection.RelativeShift.X, 0, mapDirection.RelativeShift.Y);
                }

                OnMapDirectionChanged(oldDirection, mapDirection);
            }
        }
        protected override void PerformAttack(MapDirection direction, ref int delay)
        {
            var targetTile = attackProvider.Location.Tile.Neighbors.GetTile(direction) as IHasEntity;

            if (targetTile?.Entity != null)
            {
                //F064_aadz_SOUND_RequestPlay_COPYPROTECTIOND(C16_SOUND_COMBAT, G306_i_PartyMapX, G307_i_PartyMapY, C01_MODE_PLAY_IF_PRIORITIZED);
                delay = 1000;
                F232_dzzz_GROUP_IsDoorDestroyedByAttack(targetTile.Entity, F312_xzzz_CHAMPION_GetStrength(attackProvider, ActionHandStorageType.Instance), false);
                //F064_aadz_SOUND_RequestPlay_COPYPROTECTIOND(C04_SOUND_WOODEN_THUD, G306_i_PartyMapX, G307_i_PartyMapY, C02_MODE_PLAY_ONE_TICK_LATER);
            }
            else
            {
                base.PerformAttack(direction, ref delay);
            }
        }
Exemple #36
0
        public void StartTurn()
        {
            CurrentPosition = startPoint;
            GraphicElement player = new GraphicElement("Graphics/player", CurrentPosition.Position.X, CurrentPosition.Position.Y, false, Teams[CurrentTeam].TeamColor, .75f, "PLAYER");

            CurrentDirection = CurrentPosition.GetExitDirection();
            player.SetRotation(Compass[CurrentDirection]);
            player.SetOrigin(new Vector2(14, 31));
            player.SetScale(new Vector2(.7f, .7f));
            objects.Add(player);

            AvatarShown       = true;
            RemainingTeamTime = TeamTime;
            teamCountDown     = true;
            CanMove           = true;
        }
        void F212_mzzz_PROJECTILE_Create(IGrabableItem P433_T_Thing, MapDirection P437_i_Direction, int P438_uc_KineticEnergy, int P439_uc_Attack, int P440_uc_StepEnergy)
        {
            Projectile L0467_ps_Projectile;
            Weapon     weapon = P433_T_Thing as Weapon;

            if (weapon == null)
            {
                L0467_ps_Projectile = new ImpactProjectile(P438_uc_KineticEnergy, P440_uc_StepEnergy, P439_uc_Attack, new ThrowImpact <IGrabableItem>(P433_T_Thing));
            }
            else
            {
                L0467_ps_Projectile = new ImpactProjectile(P438_uc_KineticEnergy, P440_uc_StepEnergy, P439_uc_Attack, new WeaponImpact(weapon));
            }
            L0467_ps_Projectile.Renderer = Factory.Renderers.GetProjectileSpellRenderer(L0467_ps_Projectile, P433_T_Thing.FactoryBase.Renderer.Texture);
            L0467_ps_Projectile.Run(attackProvider.Location, P437_i_Direction);
        }
        public IEnumerable<ISpaceRouteElement> GetToSide(IEntity entity, Tile currentTile, MapDirection mapDirection)
        {
            //TODO remake
            ISpace currentSpace = entity.Location.Space;// currentTile.LayoutManager.FindCurrentSpace(entity);
            ISpace destSpace = null;

            searcher.LayoutManager = currentTile.LayoutManager;
            searcher.StartSearch(AllSpaces.First(), currentSpace, 1, (space, layer, bundle) =>
            {
                if (space.Sides.Any(x => x == mapDirection))
                {
                    searcher.StopSearch();
                    destSpace = space;
                }
            });

            return destSpace != null ? searcher.GetShortestRoute(destSpace).Select(s => new FourthSpaceRouteElement(s, currentTile)) : null;
        }
Exemple #39
0
        private IEntity GetAccesibleEnemies(MapDirection partyDirection)
        {
            //TODO rework using rectangle intersection
            var targetTile = attackProvider.Location.Tile.Neighbours.GetTile(partyDirection);
            var enemy = targetTile?.LayoutManager.Entities.Where(e => attackProvider.RelationManager.IsEnemy(e.RelationManager.RelationToken)) //todo or otherwise
                .MinObj(c => Vector3.Distance(c.Position, attackProvider.Position));

            if (enemy != null)
            {
                bool isInFirstRow = attackProvider.Location.Space.Sides.Contains(partyDirection);
                if (!isInFirstRow)
                {
                    bool someBodyInFirstRow = null != attackProvider.Location.Tile.LayoutManager.Entities.FirstOrDefault(e => e.Location.Space.Sides.Contains(partyDirection));
                    if (someBodyInFirstRow)
                        return null;
                }
            }
            return enemy;
        }
Exemple #40
0
        private async Task Fight(Tile enemyTile, MapDirection moveDirection)
        {
            var sortedEnemyLocation = GroupLayout.AllSpaces
                .Where(s => s.Sides.Contains(moveDirection.Opposite))
                .Concat(GroupLayout.AllSpaces
                    .Where(s => s.Sides.Contains(moveDirection)))
                .Where(s => !enemyTile.LayoutManager.IsFree(s));

            var locEnum = sortedEnemyLocation.GetEnumerator();


            while (locEnum.MoveNext() && living)
            {
                await Task.Delay(100);

                if (enemyTile.LayoutManager.WholeTileEmpty)
                    break;

                IEntity enemy;
                do
                {
                    enemy = enemyTile.LayoutManager.GetEntities(locEnum.Current).FirstOrDefault();
                    if (enemy != null)
                    {
                        $"{enemy} hitted.".Dump();
                        await Task.Delay(attackDuration);
                        //TODO if killed reset enumerator
                        if (false)
                        {
                            locEnum.Reset();
                            break;
                        }
                    }
                }
                while (living && enemy != null);
            }
        }
 /// <summary>
 /// Удалить стену по направлению
 /// </summary>
 /// <param name="Direction">Направление</param>
 protected void RemoveWall(MapDirection Direction)
 {
     SetWall(Direction, null);
 }
 /// <summary>
 /// Задать стену по направлению
 /// </summary>
 /// <param name="Direction">Направление</param>
 /// <param name="Wall">Стена</param>
 public void SetWall(MapDirection Direction, MapWall Wall)
 {
     if (Direction == Maps.MapDirection.North) NorthWall = Wall; else
     if (Direction == Maps.MapDirection.South) SouthWall = Wall; else
     if (Direction == Maps.MapDirection.West) WestWall = Wall; else
     if (Direction == Maps.MapDirection.East) EastWall = Wall;
 }
 /// <summary>
 /// Есть ли стена по данному направлению
 /// </summary>
 /// <param name="Direction">Направление</param>
 /// <returns>Есть ли стена</returns>
 public bool HasWall(MapDirection Direction)
 {
     return GetWall(Direction) != null;
 }
        /// <summary>
        /// Adds a single action to the list that moves the party in a given direction using the default speed.
        /// </summary>
        /// <param name="actor">Actor to move on the field</param>
        /// <param name="direction">Direction to move the party</param>
        public void MoveParty(CharacterBase actor, MapDirection direction)
        {
            actor.Sprite.Motion = "Walk";

            moveSlot.Action = ActionCommand.MoveTo;
            moveSlot.Actor = actor;
            moveSlot.IsAbsolute = false;
            moveSlot.Frames = cDefaultMoveFrame;

            switch (direction)
            {
                case MapDirection.Up:
                    moveSlot.EndPosition = cMoveUp;
                    break;
                case MapDirection.Down:
                    moveSlot.EndPosition = cMoveDown;
                    break;
                case MapDirection.Left:
                    moveSlot.EndPosition = cMoveLeft;
                    break;
                case MapDirection.Right:
                    moveSlot.EndPosition = cMoveRight;
                    break;
            }

            // Mark that the moveSlot is active again
            moveSlot.Reset();
            moveSlot.Complete += PartyMoveHandler;
        }
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * set the route direction.
  * @param newDirection
  */
 public void SetMapDirection(MapDirection newDirection)
 {
     _mapDirectionLayer.SetMapDirection(newDirection);
 }
            ////////////////////////////////////////////////////////////////////////
            //--------------------------------- REVISIONS --------------------------
            // Date       Name                 Tracking #         Description
            // ---------  -------------------  -------------      ------------------
            // 18JUN2009  James Shen                 	          Initial Creation
            ////////////////////////////////////////////////////////////////////////
            /**
             *
             * @param mapDirection
             * @param X
             * @param Y
             * @param Width
             * @param Height
             */
            private void DrawRouteImage(MapDirection mapDirection, int x, int y,
                    int width, int height)
            {
                if (!_routeDrawWaypointOnly)
                {
                    _sutherlandHodgman = new SutherlandHodgman(_screenBounds);

                    ArrayList polyline = new ArrayList();
                    int minLevel = NeedShowLevel(mapDirection.Polyline.NumLevels, GetZoom());
                    for (int i = 0; i < mapDirection.Polyline.GetVertexCount(); i++)
                    {
                        int level = mapDirection.Polyline.GetLevel(i);
                        if (level >= minLevel)
                        {
                            polyline.Add(mapDirection.Polyline.GetVertex(i));
                        }
                    }
                    ArrayList clippedPts = _sutherlandHodgman.ClipPline(polyline);

                    GeoPoint newPt1;
                    GeoPoint newPt2;

                    GeoPoint drawPt1 = new GeoPoint(0, 0), drawPt2 = new GeoPoint(0, 0);
                    const int steps = 1;
                    int numOfTiles = MAP_TILE_WIDTH / _mapDrawingTileWidth;
                    Rectangle drawArea = new Rectangle();
                    Rectangle intersectRect = new Rectangle(0, 0, width, height);
                    int xIndex;
                    for (xIndex = 0; xIndex < numOfTiles; xIndex++)
                    {
                        int yIndex;
                        for (yIndex = 0; yIndex < numOfTiles; yIndex++)
                        {
                            bool hasPt1 = false;
                            GeoLatLng pt1 = null;
                            _routeGraphics2D.Clear(Color.White);
                            drawArea.X = xIndex * _mapDrawingTileWidth;
                            drawArea.Y = yIndex * _mapDrawingTileWidth;
                            drawArea.Width = drawArea.Height = _mapDrawingTileWidth;
                            drawArea = intersectRect.Intersection(drawArea);
                            int totalPointSize = clippedPts.Count;
                            if (!drawArea.IsEmpty())
                            {
                                _routeGraphics2D.SetClip(0, 0,
                                        drawArea.Width, drawArea.Height);
                                try
                                {
                                    for (int j = 0; j < totalPointSize; j += steps)
                                    {
                                        GeoLatLng pt = (GeoLatLng)clippedPts[j];
                                        int level = minLevel;
                                        if (hasPt1 == false)
                                        {
                                            if (level >= minLevel)
                                            {
                                                {
                                                    {
                                                        hasPt1 = true;
                                                        pt1 = pt;
                                                        continue;
                                                    }
                                                }
                                            }
                                        }
                                        if (hasPt1)
                                        {
                                            if (level >= minLevel)
                                            {
                                                GeoLatLng pt2 = pt;
                                                newPt1 = FromLatLngToMapPixel(pt1);
                                                newPt2 = FromLatLngToMapPixel(pt2);
                                                newPt1.X -= x + xIndex * _mapDrawingTileWidth;
                                                newPt1.Y -= y + yIndex * _mapDrawingTileWidth;
                                                newPt2.X -= x + xIndex * _mapDrawingTileWidth;
                                                newPt2.Y -= y + yIndex * _mapDrawingTileWidth;
                                                drawPt1.X = (int)newPt1.X;
                                                drawPt1.Y = (int)newPt1.Y;
                                                drawPt2.X = (int)newPt2.X;
                                                drawPt2.Y = (int)newPt2.Y;

                                                if ((drawPt1.Distance(drawPt2) > 0))
                                                {
                                                    _routeGraphics2D.DrawLine(RoutePen, (int)drawPt1.X,
                                                            (int)drawPt1.Y,
                                                            (int)drawPt2.X, (int)drawPt2.Y);
                                                    pt1 = pt2;
                                                    if (_readListener != null)
                                                    {
                                                        _readListener.readProgress(j,
                                                                totalPointSize);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                catch (Exception)
                                {

                                }
                            }

                            _routeGraphics.DrawRGB(_routeGraphics2D.GetRGB(), 0,
                                    _mapDrawingTileWidth,
                                    xIndex * _mapDrawingTileWidth,
                                    yIndex * _mapDrawingTileWidth,
                                    _mapDrawingTileWidth,
                                    _mapDrawingTileWidth, true);
                        }
                    }
                }
                else
                {
                    _routeGraphics.SetColor(TRANSPARENCY);
                    _routeGraphics.FillRect(0, 0, MAP_TILE_WIDTH, MAP_TILE_WIDTH);
                }
            }
 ////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS --------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////
 /**
  * draw route icon in given rectangle.
  * @param mapDirection
  * @param X
  * @param Y
  * @param Width
  * @param Height
  */
 private void DrawRouteIcons(MapDirection mapDirection, int x, int y,
         int width, int height)
 {
     GeoPoint newPt;
     GeoLatLng pt;
     _routeGraphics.SetClip(0, 0, width, height);
     for (int i = 0; i < mapDirection.Routes[0].Steps.Length - 1; i++)
     {
         MapStep mapStep = mapDirection.Routes[0].Steps[i];
         pt = mapStep.LastLatLng;
         if (_screenBounds.ContainsLatLng(pt))
         {
             newPt = FromLatLngToMapPixel(pt);
             newPt.X -= x;
             newPt.Y -= y;
             _routeGraphics.DrawImage(MiddleIcon,
                     (int)newPt.X - MiddleIcon.GetWidth() / 2, (int)newPt.Y - MiddleIcon.GetHeight() / 2);
         }
     }
     pt = mapDirection.Polyline.GetVertex(0);
     newPt = FromLatLngToMapPixel(pt);
     newPt.X -= x;
     newPt.Y -= y;
     _routeGraphics.DrawImage(StartIcon,
             (int)newPt.X - StartIcon.GetWidth() / 2, (int)newPt.Y - StartIcon.GetHeight() / 2);
     pt = mapDirection.Polyline.GetVertex(mapDirection.Polyline.GetVertexCount() - 1);
     newPt = FromLatLngToMapPixel(pt);
     newPt.X -= x;
     newPt.Y -= y;
     _routeGraphics.DrawImage(EndIcon,
             (int)newPt.X - EndIcon.GetWidth() / 2, (int)newPt.Y - EndIcon.GetHeight() / 2);
 }
        /// <summary>
        /// Adds a single action to the list that moves the party in a given direction using the default speed.
        /// </summary>
        /// <param name="actor">Actor to move on the field</param>
        /// <param name="direction">Direction to move the party</param>
        public void MoveNPC(CharacterBase actor, MapDirection direction)
        {
            npcSlots[actor.ID].Action = ActionCommand.WalkTo;
            npcSlots[actor.ID].Actor = actor;
            npcSlots[actor.ID].IsAbsolute = false;
            npcSlots[actor.ID].Frames = 30;

            switch (direction)
            {
                case MapDirection.Up:
                    npcSlots[actor.ID].EndPosition = cMoveUp;
                    break;
                case MapDirection.Down:
                    npcSlots[actor.ID].EndPosition = cMoveDown;
                    break;
                case MapDirection.Left:
                    npcSlots[actor.ID].EndPosition = cMoveLeft;
                    break;
                case MapDirection.Right:
                    npcSlots[actor.ID].EndPosition = cMoveRight;
                    break;
            }

            // Mark that the npcSlot is active again
            npcSlots[actor.ID].Reset();
        }
Exemple #49
0
        /// <summary>
        /// Creates new isntance of balloon,infering its body size form supplied text and linking balloon leg with control,
        /// balloon will automatically follow control position on the screen even when it changes
        /// </summary>
        /// <param name="text">Text to display inside balloon</param>
        /// <param name="font">Balloon text font, may be null in which case default font is used</param>
        /// <param name="anchorControl">Control to anchor ballon leg to</param>
        /// <param name="legLength">Length of balloon leg</param>
        /// <param name="preferredPlacement">Where balloon should be placed when multiple placement positions are equaly available</param>
        /// <param name="color">Balloon color</param>
        public Balloon(string text, 
            Font font,
            Control anchorControl,
            int legLength,
            MapDirection preferredPlacement,
            Color color)
            : base()
        {
            if (anchorControl==null)
            throw new WFormsException("Anchor controll can not be null"); //dont localize - very rare

              base.Text = text ?? string.Empty;
              if (font != null)
            Font = font;

               m_AnchorControl = anchorControl;
               m_LegLength = legLength;
               m_PreferredPlacement = preferredPlacement;

              //need this to suppress dummy window when user does ALT+TAB
              Form owner = anchorControl.FindForm();
              if (owner!=null)
             this.Owner = owner;

              findPlacementCoordinates(out m_BodyRect, out m_TargetPoint);

              ctorBody(m_BodyRect, m_TargetPoint, color);

              m_AnchorTimer = new Timer();
              m_AnchorTimer.Interval = ANCHOR_TIMER_INTERVAL;
              m_AnchorTimer.Tick += new EventHandler(m_AnchorTimer_Tick);
              m_AnchorTimer.Enabled = true;
        }
 public IEnumerable<ISpaceRouteElement> GetToSide(IEntity entity, Tile currentTile, MapDirection mapDirection)
 {
     throw new NotImplementedException();
 }
 private static MapWallState DeserializeMapWallState(BinaryReader Reader, MapWall wall, MapDirection direction)
 {
     MapWallState state = new MapWallState(wall, direction);
     state.Mode = DeserializeMapWallMode(Reader);
     state.Health = Reader.ReadUInt16();
     return state;
 }
 /// <summary>
 /// Удалить стену по направлению
 /// </summary>
 /// <param name="Direction">Направление</param>
 public void RemoveWall(MapDirection Direction)
 {
     SetWall(Direction, null);
 }
        /// <summary>
        /// Adds a single action to the list that moves the party in a given direction using the specified speed.
        /// </summary>
        /// <param name="actor">Actor to move on the field</param>
        /// <param name="direction">Direction to move the party</param>
        /// <param name="speed">Number of frames to move the actor</param>
        public void MoveParty(CharacterBase actor, MapDirection direction, int frames)
        {
            moveSlot.Action = ActionCommand.WalkTo;
            moveSlot.Actor = actor;
            moveSlot.IsAbsolute = false;
            moveSlot.Frames = frames;

            switch (direction)
            {
                case MapDirection.Up:
                    moveSlot.EndPosition = cMoveUp;
                    break;
                case MapDirection.Down:
                    moveSlot.EndPosition = cMoveDown;
                    break;
                case MapDirection.Left:
                    moveSlot.EndPosition = cMoveLeft;
                    break;
                case MapDirection.Right:
                    moveSlot.EndPosition = cMoveRight;
                    break;
            }

            // Mark that the moveSlot is active again
            moveSlot.Reset();
            //moveSlot.Complete += PartyMoveHandler;
        }
 public static void SerializeMapDirection(BinaryWriter Writer, MapDirection Direction)
 {
     Writer.Write((byte)Direction);
 }
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 03JAN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * set the route direction.
  * @param newDirection
  */
 internal void SetMapDirection(MapDirection newDirection)
 {
     _mapDirectionRenderer.SetMapDirection(newDirection);
 }
 /// <summary>
 /// Проходимость с определённой стороны
 /// </summary>
 /// <param name="Direction">Сторона</param>
 /// <returns>Проходимость</returns>
 public float GetPassbilityByDirection(MapDirection Direction)
 {
     float passablity = this.Place.Passability;
     MapWall wall = GetWall(Direction);
     if (wall != null)
         passablity -= wall.Passability;
     foreach (MapActiveObject active in ActiveObjects)
         passablity -= active.Passability;
     if (passablity < 0) passablity = 0;
     return passablity;
 }
 ////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS --------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////
 /**
  * set the route direction.
  * @param newDirection
  */
 public void SetMapDirection(MapDirection newDirection)
 {
     _currentMapDirection = newDirection;
 }
 /// <summary>
 /// Получить стену по направлению
 /// </summary>
 /// <param name="Direction">Навправление</param>
 /// <returns></returns>
 public MapWall GetWall(MapDirection Direction)
 {
     if (Direction == Maps.MapDirection.North) return NorthWall; else
     if (Direction == Maps.MapDirection.South) return SouthWall; else
     if (Direction == Maps.MapDirection.West) return WestWall; else
     if (Direction == Maps.MapDirection.East) return EastWall;
     return null;
 }
Exemple #59
0
    /// <summary>
    /// Converts map direction to angular coordinate in radians
    /// </summary>
    public static double MapDirectionToAngle(MapDirection direction)
    {
       switch (direction)
       {
         case MapDirection.North:  return 4d/16d * PI2;
         case MapDirection.South:  return 12d/16d * PI2;
         case MapDirection.East:   return 0.0d;
         case MapDirection.West:   return 8d/16d * PI2;

         case MapDirection.NorthEast: return 2d/16d * PI2;
         case MapDirection.NorthWest: return 6d/16d * PI2;
         case MapDirection.SouthEast: return 14d/16d * PI2;
         case MapDirection.SouthWest: return 10d/16d * PI2;
         
         default: return 0.0d;
       }
    }
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 20JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Default constructor.
  */
 public GDirections()
 {
     _directionQuery = new DirectionQuery();
     _mapDirection = new MapDirection();
 }