Beispiel #1
0
 public PalabraDeSopa(string palabra, Cord pos, Cord dir, bool finded)
 {
     this.palabra = palabra;
     this.pos     = pos;
     this.dir     = dir;
     finded       = false;
 }
Beispiel #2
0
    private bool fillWord(string word, Cord start, Cord end, Cord dir, bool[,] tGrid)
    {
        Cord pos = start;

        for (int i = 0; true; i++)
        {
            if (tGrid[pos.y, pos.x] == true &&
                grid[pos.y, pos.x] != word[i])
            {
                return(false);
            }


            if (pos == end)
            {
                break;
            }
            pos += dir;
        }
        pos = start;
        palabrasActivas.Add(new PalabraDeSopa(word, start, dir, false));
        for (int i = 0; true; i++)
        {
            grid[pos.y, pos.x]  = word[i];
            tGrid[pos.y, pos.x] = true;
            if (pos == end)
            {
                break;
            }
            pos += dir;
        }
        return(true);
    }
Beispiel #3
0
 public void Set(Cord xy, int value)
 {
     if (xy.OnBord(size))
     {
         map[xy.x, xy.y] = value;
     }
 }
 // Add a Cord by retrieving its "other" Hook and using it as a key
 public void Attach(Cord c)
 {
     if (!ConflictTest(c))
     {
         attached.Add(GetOtherHook(c), c);
     }
 }
        public Cord addCord(Gestures gesture, string keys)
        {
            Cord cord = new Cord(keys);

            Cords.Add(gesture, cord);
            return(cord);
        }
 // 0
 private void ShowPossibleMove(Cord C)
 {
     if (PAt(C) != null)           //click on pawn
     {
         if (PAt(C).Owner == Turn) //own pawn
         {
             move              = 1;
             movedPawn         = C;
             cordsMarkedToMove = PAt(C).ShowPossibleMove(C, A);
             ShowPawnInfo(C);
             CanSkip = true;
         }
         else //enemy pawn
         {
             ShowPawnInfo(C);
             CanSkip = false;
         }
     }
     else
     {
         CanSkip = false;
         ShowFloorInfo(C);
         Console.WriteLine("Empty field or enemy pawn was clicked");
     }
 }
Beispiel #7
0
        public virtual List <Cord> ShowPossibleMove(Cord C, Arena A)

        {
            List <Cord> cordsToUpdate = new List <Cord>();
            int         size          = Condition + A[C].MovementBonus;

            for (int i = 0; i <= size; i++)
            {
                for (int k = i; k >= -i; k--)
                {
                    if (Arena.IsOK(C, k, i - size) && A.PAt(C, k, i - size) == null)
                    {
                        A[C, k, i - size].FloorStatus = FloorStatus.Move;
                        cordsToUpdate.Add(new Cord(C, k, i - size));
                    }
                }
            }
            for (int i = 0; i < size; i++)
            {
                for (int k = i; k >= -i; k--)
                {
                    if (Arena.IsOK(C, k, size - i) && A.PAt(C, k, size - i) == null)
                    {
                        A[C, k, size - i].FloorStatus = FloorStatus.Move;
                        cordsToUpdate.Add(new Cord(C, k, size - i));
                    }
                }
            }
            A[C].FloorStatus = FloorStatus.Move;
            cordsToUpdate.Add(C);
            return(cordsToUpdate);
        }
    Vector3 CordToPosition(Cord cord, int mapWidth, int mapHeight)
    {
        float   posx     = -mapWidth / 2f + 0.5f + cord.y;
        float   posz     = -mapHeight / 2f + 0.5f + cord.x;
        Vector3 position = new Vector3(posx, 0f, posz);

        return(position);
    }
Beispiel #9
0
    public static Cord UnitaryDiference(Cord str, Cord end)
    {
        Cord res = end - str;

        res.x = (res.x > 1) ? 1 : (res.x < -1) ? -1 : res.x;
        res.y = (res.y > 1) ? 1 : (res.y < -1) ? -1 : res.y;
        return(res);
    }
Beispiel #10
0
    public static bool InDiagonal(Cord a, Cord b)
    {
        Cord delta = a - b;
        int  dx    = Math.Abs(delta.x);
        int  dy    = Math.Abs(delta.y);

        return(dx == dy);
    }
Beispiel #11
0
    public static bool InLine(Cord a, Cord b)
    {
        Cord delta = a - b;
        int  dx    = Math.Abs(delta.x);
        int  dy    = Math.Abs(delta.y);

        return(dx == 0 || dy == 0);
    }
Beispiel #12
0
 public int Get(Cord xy)
 {
     if (xy.OnBord(size))
     {
         return(map[xy.x, xy.y]);
     }
     return(0);
 }
Beispiel #13
0
 public TileNPC(string _name, bool tradable, Cord _pos)
 {
     MyType    = TileType.NPC;
     TileName  = _name;
     Tradable  = tradable;
     name      = _name;
     Pos       = _pos;
     inventory = new InventoryManager();
 }
Beispiel #14
0
        protected Pawn(bool owner, Cord cord)
        {
            turn  = Owner = owner;
            HP    = BaseHp;
            Manna = BaseManna;
            Cord  = cord;

            InitAnimation();
        }
Beispiel #15
0
        public virtual void SkillAttack(GameState gS, Cord defender, int bonus)
        {
            TurnAttack(defender);
            State          = App.attack;
            timer.Interval = RENDER_ATTACK;

            Manna -= SkillAttackCost;
            gS.PAt(defender).Def(SkillAttackDmg + bonus + gS.At(Cord).AttackBonus, gS, Cord);
        }
Beispiel #16
0
        public override void SkillAttack(GameState gameState, Cord defender, int bonus)
        {
            TurnAttack(defender);
            Manna -= SkillAttackCost;
            gameState.At(defender).SkillOwner = Owner;
            MagSkill skill = new MagSkill(defender, Owner, SkillAttackDmg + gameState.At(Cord).AttackBonus, bonus, gameState);

            gameState.AddSkill(skill);
            skill.Place();
        }
Beispiel #17
0
        public override void NormalAttack(GameState gS, Cord defender, int bonus)
        {
            TurnAttack(defender);
            State          = App.attack;
            timer.Interval = RENDER_ATTACK;

            Manna -= PrimaryAttackCost;

            gS.PAt(defender).HPRegeneration(HEAL_BASE + bonus, Cord);
        }
Beispiel #18
0
 protected Skill(Cord attackPlace, bool attackOwner, int dmg, int bonus, GameState gS, byte roundsToExec)
 {
     RoundsToExec = roundsToExec;
     AttackPlace  = attackPlace;
     AttackOwner  = attackOwner;
     Dmg          = dmg;
     Finished     = false;
     Bonus        = bonus;
     this.gS      = gS;
 }
Beispiel #19
0
 protected void TurnAttack(Cord attacker)
 {
     if (Cord.Y > attacker.Y)
     {
         turn = true;
     }
     else if (Cord.Y < attacker.Y)
     {
         turn = false;
     }
 }
Beispiel #20
0
    void Start()
    {
        firstLetterIsSelected  = false;
        secondLetterIsSelected = false;
        firstLetter            = new Cord(0, 0);
        secondLetter           = new Cord(0, 0);
        sopa = GameManager.instance.sopaActiva;

        size = GameManager.instance.level + 7;
        doshit();
    }
Beispiel #21
0
 public override bool Equals(object obj)
 {
     if ((obj == null) || !GetType().Equals(obj.GetType()))
     {
         return(false);
     }
     else
     {
         Cord p = (Cord)obj;
         return((X == p.X) && (Y == p.Y));
     }
 }
Beispiel #22
0
        // 1
        private void MovePawnToField(Cord C)
        {
            if (A[C].FloorStatus == FloorStatus.Move) // move pawn to cord
            {
                if (!movedPawn.Equals(C))             //ruch na inne pole niz obecne
                {
                    Console.WriteLine($"Pawn from {movedPawn} can be moved to {C}");

                    A[C].PawnOnField         = PAt(movedPawn);
                    A[movedPawn].PawnOnField = null;
                    movedPawn             = C;
                    move                  = 2;
                    A[C].PawnOnField.Cord = C;
                    ShowAtttack(C);
                    ShowPawnInfo(C);
                }
                else // nacisniecie na pole na ktorym byl pionek, anulowanie ruchu
                {
                    Console.WriteLine($"Canceling moving pawn from {movedPawn}, same field was clicked ({C})");
                    move = 0;
                }
                foreach (Cord cord in cordsMarkedToMove)
                {
                    A[cord].FloorStatus = FloorStatus.Normal;
                }
                CanSkip = false;
            }
            else //selecting field on which pawn cannot move
            {
                if (PAt(C) != null)
                {
                    if (PAt(C)?.Owner == Turn)//clicking at current player pawn
                    {
                        foreach (Cord cord in cordsMarkedToMove)
                        {
                            A[cord].FloorStatus = FloorStatus.Normal;
                        }
                        ShowPossibleMove(C);
                        ShowPawnInfo(C);
                    }
                    else //clicking at enemy pawn
                    {
                        ShowPawnInfo(C);
                        CanSkip = false;
                    }
                }
                else //empty field
                {
                    ShowFloorInfo(C);
                    CanSkip = false;
                }
            }
        }
Beispiel #23
0
    private void FillGrid()
    {
        int cont = 0;

        char[,] oGrid = new char[size, size];
        Cord[] directions = new Cord[8];
        directions[0] = new Cord(0, -1);
        directions[1] = new Cord(1, -1);
        directions[2] = new Cord(1, 0);
        directions[3] = new Cord(1, 1);
        directions[4] = new Cord(0, 1);
        directions[5] = new Cord(-1, 1);
        directions[6] = new Cord(-1, 0);
        directions[7] = new Cord(-1, -1);
        Cord dir;
        Cord start;
        Cord endPos;
        int  len;

        bool[,] takedGrid = new bool[size, size];

        for (int i = 0; i < size; i++)
        {
            for (int j = 0; j < size; j++)
            {
                char ch = RandomChar();
                grid[i, j] = ch;

                takedGrid[i, j] = false;
            }
        }
        foreach (string word in words)
        {
            len = word.Length;
            while (true)
            {
                cont++;
                if (cont >= 10000)
                {
                    Debug.Log("PANIC PANIC PANIC PANIC PANIC PANIC");
                    return;
                }
                dir   = directions[random.Next(0, 8)];
                start = new Cord(random.Next(0, size), random.Next(0, size));

                endPos = start + dir * (len - 1);
                if (validPos(endPos) && fillWord(word, start, endPos, dir, takedGrid))
                {
                    break;
                }
            }
        }
    }
        private void UpdateCord()
        {
            Cord cord;

            if (Cords.TryGetValue(currentGesture, out cord))
            {
                currentCord = cord;
            }
            else
            {
                currentCord = null;
            }
        }
Beispiel #25
0
        public override List <Cord> ShowPossibleAttack(Cord C, Arena A, bool attackType)
        {
            if (attackType)
            {
                List <Cord> cordsToUpdate = new List <Cord>();
                int         size          = PrimaryAttackRange + 1;

                for (int i = 1; i < size; i++)
                {
                    for (int k = i; k >= -i; k--)
                    {
                        if (Arena.IsOK(C, k, i - size))
                        {
                            A[C, k, i - size].FloorStatus = FloorStatus.Attack;
                            cordsToUpdate.Add(new Cord(C, k, i - size));
                        }
                    }
                }

                for (int i = 1; i < size; i++)
                {
                    for (int k = i; k >= -i; k--)
                    {
                        if (Arena.IsOK(C, k, size - i))
                        {
                            A[C, k, size - i].FloorStatus = FloorStatus.Attack;
                            cordsToUpdate.Add(new Cord(C, k, size - i));
                        }
                    }
                }

                for (int k = 1 - size; k <= size - 1; k++)
                {
                    if (Arena.IsOK(C, k, 0))
                    {
                        A[C, k, 0].FloorStatus = FloorStatus.Attack;
                        cordsToUpdate.Add(new Cord(C, k, 0));
                    }
                }


                A[C].FloorStatus = FloorStatus.Attack;
                cordsToUpdate.Add(C);
                return(cordsToUpdate);
            }
            else
            {
                return(base.ShowPossibleAttack(C, A, attackType));
            }
        }
Beispiel #26
0
        public void Draw(Cord _Pos)
        {
            CW.Clear();
            Pos           = _Pos;
            LineHeightPos = 0;
            string BigLine = Side + " Round: " + SingleTon.GetPlayerController().CBM.Rounds + " " + Side;

            CW.FillOutStringBorder(BigLine, true, Pos.X, Pos.Y + LineHeightPos);
            LineHeightPos++;
            CW.Write(BigLine, Pos.X, Pos.Y + LineHeightPos);
            LineHeightPos++;
            CW.FillOutStringBorder(BigLine, false, Pos.X, Pos.Y + LineHeightPos);
            LineHeightPos++;
            BigLine = Side + " Name: " + SingleTon.GetPlayerController().PlayerName + " " + Side;
            CW.Write("", Pos.X, Pos.Y + LineHeightPos);
            LineHeightPos++;
            CW.FillOutStringBorder(BigLine, true, Pos.X, Pos.Y + LineHeightPos);
            LineHeightPos++;
            CW.Write(BigLine, Pos.X, Pos.Y + LineHeightPos);
            LineHeightPos++;
            CW.FillOutStringBorder(BigLine, false, Pos.X, Pos.Y + LineHeightPos);
            LineHeightPos += 2;
            StatsPosStart  = new Cord {
                X = Pos.X, Y = Pos.Y + LineHeightPos
            };
            ReDrawStats();
            LineHeightPos  += 9;
            ActionMenuStart = new Cord {
                X = Pos.X, Y = Pos.Y + LineHeightPos
            };
            RedrawAcionMenu();
            LineHeightPos = 10 + ActionMenuStart.Y;
            LogPosStart   = new Cord {
                X = Pos.X, Y = Pos.Y + LineHeightPos
            };
            ReDrawLog();

            //Other Side
            BigLine = Side + " Name: " + SingleTon.GetPlayerController().CBM.enemyFighting.Name + " " + Side;
            Pos     = new Cord()
            {
                X = Console.WindowWidth - (BigLine.Length + 1), Y = Pos.Y + 4
            };
            LineHeightPos = 0;
            CW.FillOutStringBorder(BigLine, true, Pos.X, Pos.Y + LineHeightPos);
            LineHeightPos++;
            CW.Write(BigLine, Pos.X, Pos.Y + LineHeightPos);
            LineHeightPos++;
            CW.FillOutStringBorder(BigLine, false, Pos.X, Pos.Y + LineHeightPos);
        }
Beispiel #27
0
 public virtual void HPRegeneration(int hp, Cord healer)
 {
     Console.WriteLine($"Pawn at {Cord} healed by {healer} with {hp} hp");
     TurnDef(healer);
     State          = App.move; //def
     timer.Interval = RENDER_DEF;
     if (HP + hp > BaseHp)
     {
         HP = BaseHp;
     }
     else
     {
         HP += hp;
     }
 }
Beispiel #28
0
        public virtual void Def(int dmg, GameState gS, Cord attacker)
        {
            TurnDef(attacker);
            State          = App.move; //def
            timer.Interval = RENDER_DEF;

            double reduction = (Convert.ToDouble(Armor) + gS.At(Cord).DefBonus) / 10.0;
            int    savedHP   = (int)(reduction * dmg);

            HP -= (dmg - savedHP); //1 armor point reduce 10% of dmg
            if (HP <= 0)
            {
                Dead(gS);
            }
        }
Beispiel #29
0
        public override bool IsSomeoneToAttack(Cord C, Arena A, bool attackType)
        {
            if (attackType)
            {
                int size = PrimaryAttackRange + 1;

                if (Manna < PrimaryAttackCost)
                {
                    return(false);
                }

                for (int i = 1; i < size; i++)
                {
                    for (int k = i; k >= -i; k--)
                    {
                        if (Arena.IsOK(C, k, i - size) && A.PAt(C, k, i - size) != null && A.PAt(C, k, i - size).Owner != Owner)
                        {
                            return(true);
                        }
                    }
                }

                for (int i = 1; i < size; i++)
                {
                    for (int k = i; k >= -i; k--)
                    {
                        if (Arena.IsOK(C, k, size - i) && A.PAt(C, k, size - i) != null && A.PAt(C, k, size - i).Owner != Owner)
                        {
                            return(true);
                        }
                    }
                }

                for (int k = 1 - size; k <= size - 1; k++)
                {
                    if (Arena.IsOK(C, k, 0) && A.PAt(C, k, 0) != null && A.PAt(C, k, 0).Owner != Owner)
                    {
                        return(true);
                    }
                }

                return(false);
            }
            else
            {
                return(base.IsSomeoneToAttack(C, A, attackType));
            }
        }
Beispiel #30
0
    }//public ActionResult GoogleMap

    private List<GeoLocation> toPoints(String PointList) {
      var AllPoints = new List<GeoLocation>();
      PointList = PointList.Replace("POLYGON ((", "");
      PointList = PointList.Replace("))", "");

      foreach (String Cord in PointList.Split(',')) {
        var LatLnt = Cord.Trim().Split(' ');
        var thisCord = new GeoLocation {
          Latitude = Util.toDouble(LatLnt[1]),
          Longitude = Util.toDouble(LatLnt[0])
        };
        AllPoints.Add(thisCord);
      }//foreach

      return AllPoints;
    }
Beispiel #31
0
        public void Attack(byte x, byte y, byte nx, byte ny, byte p)
        {
            if (phase == PhaseType.Attack && player == p)
            {
                if (field[x, y].player == p)
                {
                    if (x == nx && y == ny && (field[x, y].fig == FigType.AB || field[x, y].fig == FigType.NB))
                    {
                        ExplodeBomb(x, y, field[x, y].fig == FigType.AB);
                        PhaseChange(PhaseType.Move, p);
                    }
                    else if (Math.Abs(nx - x) + Math.Abs(ny - y) == 1)
                    {
                        if (field[nx, ny].player == 0 && field[nx, ny].fig != FigType.Null)
                        {
                            field[nx, ny] = new Fig(field[nx, ny].fig, p);
                            Log(new Event
                            {
                                type = EventType.Capture,
                                from = new Cord(x, y),
                                to = new Cord(nx, ny),
                                player = p
                            });
                            PhaseChange(PhaseType.Move, Opponent(p));
                        }
                        else if (field[nx, ny].player == Opponent(p))
                        {
                            FigType oppfig = field[nx, ny].fig;
                            FigType fig = field[x, y].fig;

                            if (fig == FigType.Av || fig == FigType.Es || fig == FigType.Kr || fig == FigType.KrPl || fig == FigType.Lk || fig == FigType.Pl || fig == FigType.Rd || fig == FigType.St || fig == FigType.Tk || fig == FigType.Tp || fig == FigType.Tr)
                            {
                                if (oppfig == FigType.F)
                                {
                                    Destroy(nx, ny);
                                    PhaseChange(PhaseType.Move, p);
                                }
                                else if (oppfig == FigType.Rk || oppfig == FigType.Sm)
                                {
                                    Destroy(x, y);
                                    Destroy(nx, ny);
                                    PhaseChange(PhaseType.Move, Opponent(p));
                                }
                                else if (oppfig == FigType.Mn || oppfig == FigType.T || oppfig == FigType.Br)
                                {
                                    if (fig == FigType.Tr)
                                    {
                                        Destroy(nx, ny);
                                        PhaseChange(PhaseType.Move, p);
                                    }
                                    else
                                    {
                                        Destroy(x, y);
                                        Destroy(nx, ny);
                                        PhaseChange(PhaseType.Move, Opponent(p));
                                    }
                                }
                                else if (oppfig == FigType.AB || oppfig == FigType.NB)
                                {
                                    ExplodeBomb(nx, ny, oppfig == FigType.AB);
                                    PhaseChange(PhaseType.Move, Opponent(p));
                                }
                                else
                                {
                                    if (oppfig == FigType.KrPl || oppfig == FigType.Pl || oppfig == FigType.Tp)
                                    {
                                        if (fig == oppfig)
                                        {
                                            EventAttack(x, y, nx, ny, false, p);
                                            Destroy(x, y);
                                            Destroy(nx, ny);
                                            PhaseChange(PhaseType.Move, Opponent(p));
                                        }
                                        if (oppfig == FigType.Tp || (oppfig == FigType.Pl && fig != FigType.Lk) || (oppfig == FigType.KrPl && (fig == FigType.Kr || fig == FigType.Es || fig == FigType.Rd)))
                                        {
                                            EventAttack(x, y, nx, ny, true, p);
                                            Destroy(nx, ny);
                                            PhaseChange(PhaseType.Move, p);
                                        }
                                        else
                                        {
                                            EventAttack(x, y, nx, ny, false, p);
                                            Destroy(x, y);
                                            PhaseChange(PhaseType.Move, Opponent(p));
                                        }
                                    }
                                    else
                                    {
                                        blocks[0] = null;
                                        blocks[1] = null;
                                        inask[p-1] = new Cord(x, y);
                                        inask[Opponent(p)-1] = new Cord(nx, ny);
                                        PhaseChange(PhaseType.Asking, p);
                                    }
                                }
                            }
                            else
                                throw new IllegalActionException("Этим кораблем нельзя атаковать");
                        }
                        else
                            throw new IllegalActionException("Атаковать можно только корабль противника");
                    }
                    else
                        throw new IllegalActionException("Слишком далеко");
                }
                else
                    throw new IllegalActionException("Вы пытаетесь атаковать кораблем противника");
            }
            else
                throw new IllegalActionException("Вы сейчас не можете атаковать");
        }