示例#1
0
 private static void _destroyPiece(BasePiece p)
 {
     p.Destructor();
     Destroy(p.gameObject);
 }
示例#2
0
        private void _highlightMoves(BasePiece piece)
        {
            for (int i = 0; i < piece.Moves.Count; i++)
            {
                Vector2 p = piece.pos + piece.Moves[i];

                if (p.x < 0 || p.y < 0)
                {
                    continue;
                }
                if (!_canMoveToCellAt(p, piece))
                {
                    continue;
                }

                Cell cell = GetCellAt(p);

                if (!cell)
                {
                    continue;
                }
                if (cell.Piece && !cell.Piece.IsInteractableWith(piece) && cell.Piece.Type != TypePiece.BUILDING_HOME)
                {
                    continue;                                                                                                                    // can move only to empty cell or home
                }
                _createHighLightAt(p, piece.pos);
            }

            if (piece.InteractiveMoves != null)
            {
                for (int i = 0; i < piece.InteractiveMoves.Count; i++)
                {
                    Vector2 p = piece.pos + piece.InteractiveMoves[i].Move;
                    if (p.x < 0 || p.y < 0 || !GetCellAt(p) || !_canMoveToCellAt(p, piece, true))
                    {
                        continue;
                    }
                    _createHighLightAt(p, piece.pos);
                }
            }

            if (piece.MovesAttack != null)
            {
                for (int i = 0; i < piece.MovesAttack.Count; i++)
                {
                    Vector2 p = piece.pos + piece.MovesAttack[i];

                    if (p.x < 0 || p.y < 0)
                    {
                        continue;
                    }
                    if (!_canMoveToCellAt(p, piece))
                    {
                        continue;
                    }

                    Cell cell = GetCellAt(p);

                    if (!cell)
                    {
                        continue;
                    }

                    BasePiece pieceTo = cell.Piece;
                    if (!pieceTo)
                    {
                        continue;                               // can attack to not empty cell
                    }
                    if (pieceTo.Relation != PieceRelation.ENEMY && !cell.HasFight)
                    {
                        continue;                                                                                // can attack only enemy or fightcell
                    }
                    _createHighLightAt(p, piece.pos);
                }
            }

            _createHighLightAt(piece.pos, piece.pos, true);
        }
示例#3
0
 private void Damage(BasePiece target, int dmg)
 {
     target.TakeDmg(dmg);
 }
示例#4
0
 public void EnqueueBasePiecePlaced(BasePiece basePiece)
 {
     Enqueue(new BasePiecePlacedEvent(basePiece));
 }
示例#5
0
 private void _addPiece(BasePiece piece)
 {
     Cells[(int)piece.pos.y, (int)piece.pos.x].Piece = piece;
 }
示例#6
0
    public override void PostMoveSkill()
    {
        BasePiece targetPiece = mPostMoveCell.mCurrentPiece;

        if (Type[1] == "Cleric")
        {
            int distanceX = Mathf.Abs(targetPiece.mCurrentCell.mBoardPosition.x - mCurrentCell.mBoardPosition.x);
            int distanceY = Mathf.Abs(targetPiece.mCurrentCell.mBoardPosition.y - mCurrentCell.mBoardPosition.y);
            if ((distanceX + distanceY) > 1)
            {
                targetPiece.Heal(Mathf.CeilToInt(targetPiece.Stats[4] / 2f));
            }
            else
            {
                targetPiece.Heal(targetPiece.Stats[4]);
            }
            targetPiece.animFX.enabled = true;
            targetPiece.PostMoveAnimation("Heal");
            transform.position = mCurrentCell.gameObject.transform.position;
            targetPiece.SendInfo();
            mPostMoveCell = null;
            mPieceManager.SwitchSides(mColor);
            mPieceManager.ResetBonuses();
            mPieceManager.clickedPiece = null;
            clickedUnit = false;
        }
        if (Type[1] == "Dancer")
        {
            if (promoted)
            {
                targetPiece.danced = 2;
            }
            else
            {
                targetPiece.danced = 1;
            }
            targetPiece.PostMoveAnimation("Dance");
            pieceState = PieceState.Friendly;
            targetPiece.danceBlissCount = 2;
            targetPiece.SendInfo();
            mPieceManager.CrossArrowAnimations();
            mPostMoveCell              = null;
            targetPiece.pieceState     = PieceState.Waiting;
            transform.position         = mCurrentCell.gameObject.transform.position;
            mPieceManager.clickedPiece = null;
            clickedUnit = false;
            targetPiece = null;
        }
        if (Type[1] == "Troubadour")
        {
            transform.position = mCurrentCell.gameObject.transform.position;
            pieceState         = PieceState.SelectedAdjacent;
            if (targetPiece.pieceState == PieceState.Friendly)
            {
                targetPiece.anim.enabled = true;
                targetPiece.PostMoveAnimation("Warp");
                pieceState = PieceState.SelectedAdjacent;
                CheckPathing(5);
                ShowPlacementOutlines();
            }
            else
            {
                StartCoroutine(Entrap());
            }
        }
        if (Type[1] == "Heron")
        {
            targetPiece.animFX.enabled = true;
            targetPiece.PostMoveAnimation("Bliss");
            targetPiece.Heal(targetPiece.Stats[4]);
            targetPiece.blissed = true;
            targetPiece.SendInfo();
            pieceState = PieceState.Friendly;
            targetPiece.danceBlissCount = 2;
            mPieceManager.CrossArrowAnimations();
            mPostMoveCell              = null;
            targetPiece.pieceState     = PieceState.Waiting;
            transform.position         = mCurrentCell.gameObject.transform.position;
            clickedUnit                = false;
            mPieceManager.clickedPiece = null;
            targetPiece                = null;
        }
        ClearTileOutline();
    }
示例#7
0
    public void Battle(BasePiece attacker, BasePiece defender)
    {
        NihilChecks(attacker, defender);
        D10Skills(attacker, defender);
        D4Skills(attacker, defender);
        wheel.Colors(attacker.spriteColor);
        wheel.attackerColor = attacker.spriteColor;
        wheel.defenderColor = defender.spriteColor;
        int avoid = AvoidCalculator(attacker, defender, defender.Stats[3]);

        Debug.Log((object)("Final Avo was: " + avoid));
        SetWheelTextValues(attacker, avoid);
        wheel.transform.SetAsLastSibling();
        int Hitrate = HitCalculator();

        Debug.Log((object)("Hitrate was: " + Hitrate));
        if (Hitrate > avoid)
        {
            attacker.atkConfirm    = true;
            wheel.animationsCalled = 2;
            int dmg = DamageCalculator(attacker, defender);
            Debug.Log((object)("Final Dmg: " + dmg));
            defender.Stats[0] -= dmg;
        }
        else
        {
            attacker.atkConfirm    = false;
            wheel.animationsCalled = 1;
            Debug.Log((object)"Missed Attack");
        }
        wheel.SpinBegin(attacker);
        if (defender.Stats[0] <= 0)
        {
            if (!miracle)
            {
                defender.Stats[0] = 0;
                if (attacker.Skills[1] == "Lifetaker" && attacker.promoted)
                {
                    attacker.Stats[0] = attacker.Stats[4];
                }
                attacker.killConfirm = true;
                Debug.Log((object)"Defender died");
            }
            else
            {
                defender.Stats[0] = 1;
            }
        }
        else
        {
            attacker.killConfirm = false;
            Debug.Log((object)"Defender survived");
        }
        if (attacker.Skills[1] == "Grisly Wound" && attacker.promoted)
        {
            defender.Stats[0] -= 2;
            if (defender.Stats[0] < 1)
            {
                defender.Stats[0] = 1;
            }
        }
    }
 public void ExecuteKnightCommand(object obj)
 {
     SelectedPiece = new Knight(0, 0, _isWhite);
     DialogResult  = true;
 }
 public void ExecuteQueenCommand(object obj)
 {
     SelectedPiece = new Queen(0, 0, _isWhite);
     DialogResult  = true;
 }
示例#10
0
        void LearnHowToStart(
            BoardState boardState,
            NeuralNetwork neuralNetwork,
            Player playedAs)
        {
            var learningRate = .02d;
            var stopTraining = false;

            for (int a = 0; a < 100; a++)
            //while(!stopTraining)
            {
                var inputs = GetInputsFromBoard(boardState, playedAs);

                var       outputs         = neuralNetwork.ForwardPass(inputs);
                var       training        = new double[outputs.Length];
                var       error           = 0d;
                var       maxValue        = 0d;
                BasePiece maxValuePiece   = null;
                var       allAllowedMoves = new List <(int y, int x)>();

                //> Populate training data where AI should click first
                for (int i = 0; i < outputs.Length / 2; i++)
                {
                    int y = i / 8;
                    int x = i % 8;

                    if (boardState.Squares[y, x] != null &&
                        boardState.Squares[y, x].ControlledBy == playedAs)
                    {
                        training[i] = 1;

                        // For now let's just select all possible moves;
                        allAllowedMoves.AddRange(boardState.Squares[y, x].GetAllowedMoves(boardState));

                        //if (outputs[i] > maxValue)
                        //{
                        //    maxValue = outputs[i];
                        //    maxValuePiece = boardState.Squares[y, x];
                        //}
                    }

                    error += Math.Pow(outputs[i] - training[i], 2);
                    //error += outputs[i] - training[i];
                }
                //<

                //var allowedMoves = maxValuePiece.GetAllowedMoves(boardState);

                //boardState.GetPieceLocation(maxValuePiece)

                //> Populate training data where player should click second
                for (int i = outputs.Length / 2; i < outputs.Length; i++)
                {
                    int y = (i - outputs.Length / 2) / 8;
                    int x = i % 8;

                    //if (allowedMoves.Any(l => l.y == y && l.x == x))
                    //{
                    //    training[i] = 1;
                    //}

                    if (allAllowedMoves.Any(l => l.y == y && l.x == x))
                    {
                        training[i] = 1;
                    }
                    error += training[i] - outputs[i];
                }
                //<
                error /= 2;

                //var error = desiredOutput[randomTrainningIndex] - neuralNetwork.Outputs[neuralNetwork.Outputs.Length - 1][0];
                //Console.WriteLine(randomTrainningIndex + "Error: " + error);
                Debug.WriteLine("error: " + error);
                neuralNetwork.ApplyBackpropagation(training, learningRate);
            }
        }
 public void ExecuteRookCommand(object obj)
 {
     SelectedPiece = new Rook(0, 0, _isWhite);
     DialogResult  = true;
 }
    public static string PieceToStr(BasePiece currentPiece)
    {
        var message = "";

        switch (currentPiece.GetType().ToString())
        {
        case "Pawn":
            if (currentPiece.mainColor == Color.black)
            {
                message += "♟ (Черные " + currentPiece.GetType() + ")";
            }
            else if (currentPiece.mainColor == Color.white)
            {
                message += "♙ (Белые " + currentPiece.GetType() + ")";
            }
            break;

        case "Rook":
            if (currentPiece.mainColor == Color.black)
            {
                message += "♖ (Черные " + currentPiece.GetType() + ")";
            }
            else if (currentPiece.mainColor == Color.white)
            {
                message += "♜ (Белые " + currentPiece.GetType() + ")";
            }
            break;

        case "Knight":
            if (currentPiece.mainColor == Color.black)
            {
                message += "♞ (Черные " + currentPiece.GetType() + ")";
            }
            else if (currentPiece.mainColor == Color.white)
            {
                message += "♘ (Белые " + currentPiece.GetType() + ")";
            }
            break;

        case "Bishop":
            if (currentPiece.mainColor == Color.black)
            {
                message += "♝ (Черные " + currentPiece.GetType() + ")";
            }
            else if (currentPiece.mainColor == Color.white)
            {
                message += "♗ (Белые " + currentPiece.GetType() + ")";
            }
            break;

        case "Queen":
            if (currentPiece.mainColor == Color.black)
            {
                message += "♛ (Черные " + currentPiece.GetType() + ")";
            }
            else if (currentPiece.mainColor == Color.white)
            {
                message += "♕ (Белые " + currentPiece.GetType() + ")";
            }
            break;

        case "King":
            if (currentPiece.mainColor == Color.black)
            {
                message += "♚ (Черные " + currentPiece.GetType() + ")";
            }
            else if (currentPiece.mainColor == Color.white)
            {
                message += "♔ (Белые " + currentPiece.GetType() + ")";
            }
            break;

        default:
            Debug.Log("Неизвестная фигура!!!");
            break;
        }

        return(message);
    }
示例#13
0
 private bool _isKilling(BasePiece attacker, BasePiece defender)
 {
     return(defender.Stats.health <= attacker.Stats.attack);
 }
示例#14
0
        public static void Interact(Cell c1, Cell c2)
        {
            InteractionType type = GetType(c1, c2);

            if (type == InteractionType.KING_TO_HORSE)
            {
                c1.Piece.zIndex        = ZIndex.UI_ANIMATING_PIECE_MOVE;
                c1.Piece.Stats.visible = false;
                GameEngine.GameController.MoveAndScalePieceCallback(c1.Piece, c2.Pos, 0.6f, Vector3.zero, delegate
                {
                    BasePiece newPiece    = Game.Board.CreatePieceFromChar(TypePiece.KING_HORSE);
                    newPiece.Stats.attack = c1.Piece.Stats.attack + c2.Piece.Stats.attack;
                    newPiece.Stats.health = c1.Piece.Stats.health + c2.Piece.Stats.health;

                    _destroyPiece(c1.Piece);
                    _destroyPiece(c2.Piece);
                    c1.Piece = null;
                    c2.Piece = null;

                    newPiece.SetBoardPosition(c2.Pos);
                    c2.Piece = newPiece;

                    newPiece.Relation = PieceRelation.SELF;

                    GameEngine.GameController.MomentInteractionComplete();
                });
            }
            else if (type == InteractionType.KING_FROM_HORSE)
            {
                BasePiece newPiece2 = Game.Board.CreatePieceFromChar(TypePiece.KING);
                BasePiece newPiece1 = Game.Board.CreatePieceFromChar(TypePiece.HORSE);

                int health = c1.Piece.Stats.health;

                if (health == 1)
                {
                    newPiece2.Stats.health = 0;
                    newPiece1.Stats.health = 1;
                }
                else
                {
                    int maxHealth = newPiece1.Stats.health;
                    newPiece1.Stats.health = (int)health / 2;
                    if (newPiece1.Stats.health > maxHealth)
                    {
                        newPiece1.Stats.health = maxHealth;
                    }

                    newPiece2.Stats.health = health - newPiece1.Stats.health;
                }


                _destroyPiece(c1.Piece);

                c1.Piece = newPiece1;
                c2.Piece = newPiece2;

                newPiece1.pos = c1.Pos;
                newPiece2.pos = c1.Pos;

                GameEngine.GameController.MovePieceTo(newPiece2, c2.Pos);

                newPiece1.Relation = PieceRelation.SELF;
                newPiece2.Relation = PieceRelation.SELF;
            }
        }
示例#15
0
 public void RemoveBase(BasePiece b)
 {
     bases.Remove(b);
 }
 public void ExecuteBishopCommand(object obj)
 {
     SelectedPiece = new Bishop(0, 0, _isWhite);
     DialogResult  = true;
 }
示例#17
0
 public List <UnitPiece> GetUnitsAtBase(BasePiece b)
 {
     return(b.UnitsInOrbit);
 }
        public void BaseDataTest()
        {
            foreach (PersistedWorldData worldDataAfter in worldsDataAfter)
            {
                for (int index = 0; index < worldData.BaseData.CompletedBasePieceHistory.Count; index++)
                {
                    BasePiece basePiece      = worldData.BaseData.CompletedBasePieceHistory[index];
                    BasePiece basePieceAfter = worldDataAfter.BaseData.CompletedBasePieceHistory[index];

                    Assert.AreEqual(basePiece.Id, basePieceAfter.Id, "BaseData.CompletedBasePieceHistory.Id is not equal");
                    Assert.AreEqual(basePiece.ItemPosition, basePieceAfter.ItemPosition, "BaseData.CompletedBasePieceHistory.ItemPosition is not equal");
                    Assert.AreEqual(basePiece.Rotation, basePieceAfter.Rotation, "BaseData.CompletedBasePieceHistory.Rotation is not equal");
                    Assert.AreEqual(basePiece.TechType, basePieceAfter.TechType, "BaseData.CompletedBasePieceHistory.TechType is not equal");
                    Assert.AreEqual(basePiece.ParentId, basePieceAfter.ParentId, "BaseData.CompletedBasePieceHistory.ParentId is not equal");
                    Assert.AreEqual(basePiece.CameraPosition, basePieceAfter.CameraPosition, "BaseData.CompletedBasePieceHistory.CameraPosition is not equal");
                    Assert.AreEqual(basePiece.CameraRotation, basePieceAfter.CameraRotation, "BaseData.CompletedBasePieceHistory.CameraRotation is not equal");
                    Assert.AreEqual(basePiece.ConstructionAmount, basePieceAfter.ConstructionAmount, "BaseData.CompletedBasePieceHistory.ConstructionAmount is not equal");
                    Assert.AreEqual(basePiece.ConstructionCompleted, basePieceAfter.ConstructionCompleted, "BaseData.CompletedBasePieceHistory.ConstructionCompleted is not equal");
                    Assert.AreEqual(basePiece.IsFurniture, basePieceAfter.IsFurniture, "BaseData.CompletedBasePieceHistory.IsFurniture is not equal");
                    Assert.AreEqual(basePiece.BaseId, basePieceAfter.BaseId, "BaseData.CompletedBasePieceHistory.BaseId is not equal");
                    Assert.AreEqual(basePiece.BuildIndex, basePieceAfter.BuildIndex, "BaseData.CompletedBasePieceHistory.BuildIndex is not equal");

                    switch (basePiece.RotationMetadata.Value)
                    {
                    case AnchoredFaceRotationMetadata anchoredMetadata when basePieceAfter.RotationMetadata.Value is AnchoredFaceRotationMetadata anchoredMetadataAfter:
                        Assert.AreEqual(anchoredMetadata.Cell, anchoredMetadataAfter.Cell, "BaseData.RotationMetadata.Cell (AnchoredFaceRotationMetadata) is not equal");
                        Assert.AreEqual(anchoredMetadata.Direction, anchoredMetadataAfter.Direction, "BaseData.RotationMetadata.Direction (AnchoredFaceRotationMetadata) is not equal");
                        Assert.AreEqual(anchoredMetadata.FaceType, anchoredMetadataAfter.FaceType, "BaseData.RotationMetadata.FaceType (AnchoredFaceRotationMetadata) is not equal");
                        break;

                    case BaseModuleRotationMetadata baseModuleMetadata when basePieceAfter.RotationMetadata.Value is BaseModuleRotationMetadata baseModuleMetadataAfter:
                        Assert.AreEqual(baseModuleMetadata.Cell, baseModuleMetadataAfter.Cell, "BaseData.RotationMetadata.Cell (BaseModuleRotationMetadata) is not equal");
                        Assert.AreEqual(baseModuleMetadata.Direction, baseModuleMetadataAfter.Direction, "BaseData.RotationMetadata.Direction (BaseModuleRotationMetadata) is not equal");
                        break;

                    case CorridorRotationMetadata corridorMetadata when basePieceAfter.RotationMetadata.Value is CorridorRotationMetadata corridorMetadataAfter:
                        Assert.AreEqual(corridorMetadata.Rotation, corridorMetadataAfter.Rotation, "BaseData.RotationMetadata.Rotation (CorridorRotationMetadata) is not equal");
                        break;

                    case MapRoomRotationMetadata mapRoomMetadata when basePieceAfter.RotationMetadata.Value is MapRoomRotationMetadata mapRoomMetadataAfter:
                        Assert.AreEqual(mapRoomMetadata.CellType, mapRoomMetadataAfter.CellType, "BaseData.RotationMetadata.CellType (MapRoomRotationMetadata) is not equal");
                        Assert.AreEqual(mapRoomMetadata.ConnectionMask, mapRoomMetadataAfter.ConnectionMask, "BaseData.RotationMetadata.ConnectionMask (MapRoomRotationMetadata) is not equal");
                        break;

                    case null when basePieceAfter.RotationMetadata.Value is null:
                        break;

                    default:
                        Assert.Fail("BaseData.RotationMetadata is not equal");
                        break;
                    }

                    switch (basePiece.Metadata.Value)
                    {
                    case SignMetadata signMetadata when basePieceAfter.Metadata.Value is SignMetadata signMetadataAfter:
                        Assert.AreEqual(signMetadata.Text, signMetadataAfter.Text, "BaseData.Metadata.Text (SignMetadata) is not equal");
                        Assert.AreEqual(signMetadata.ColorIndex, signMetadataAfter.ColorIndex, "BaseData.Metadata.ColorIndex (SignMetadata) is not equal");
                        Assert.AreEqual(signMetadata.ScaleIndex, signMetadataAfter.ScaleIndex, "BaseData.Metadata.ScaleIndex (SignMetadata) is not equal");
                        Assert.IsTrue(signMetadata.Elements.SequenceEqual(signMetadataAfter.Elements), "BaseData.Metadata.Elements (SignMetadata) is not equal");
                        Assert.AreEqual(signMetadata.Background, signMetadataAfter.Background, "BaseData.Metadata.Background (SignMetadata) is not equal");
                        break;

                    case null when basePieceAfter.Metadata.Value is null:
                        break;

                    default:
                        Assert.Fail("BaseData.Metadata is not equal");
                        break;
                    }
                }
            }
        }
示例#19
0
    private int DamageCalculator(BasePiece attacker, BasePiece defender, bool battleCalc = true)
    {
        PreBattleTrample = false;
        int initialDamage;

        if (battleCalc) //will calculate damage normallly, prebattles require this to be false for bonus damage calculation
        {
            if (!attacker.blissed)
            {
                //calculates random damage
                initialDamage = Random.Range(1, 7);
                wheel.atk     = initialDamage;
                if (attacker.Type[1] == "Beaststone")
                {
                    initialDamage++;
                }
                if (initialDamage < attacker.Stats[1])
                {
                    initialDamage = attacker.Stats[1];
                }
                if (initialDamage > attacker.Stats[2])
                {
                    initialDamage = attacker.Stats[2];
                }
            }
            else
            {
                initialDamage = attacker.Stats[2];
                wheel.atk     = 6;
            }
        }
        else
        {
            initialDamage = 0;
        }
        int finalDamage = initialDamage;

        if (attacker.Type[1] == "Wyvern Rider" && defender.Type[0] != "Knight" && !NihilNegationDef)
        {
            PreBattleTrample = true;
            finalDamage     += 2;
        }
        if (attacker.pieceState == PieceState.Enemy && attacker.Skills[1] == "Strong Riposte" && attacker.promoted && !NihilNegationDef)
        {
            finalDamage += 3;
        }
        if (attacker.pieceState == PieceState.Waiting && attacker.Skills[1] == "Quickdraw" && attacker.promoted && !NihilNegationDef)
        {
            finalDamage += 3;
        }
        if (criticalHit)
        {
            finalDamage *= 2;
        }
        if (attacker.promoted && attacker.Skills[1] == "Heavy Blade" && !NihilNegationDef)
        {
            finalDamage += 3;
        }
        if (defender.promoted && defender.Skills[1] == "Dancing Blade" && !NihilNegationAtk)
        {
            finalDamage++;
        }
        if (AstraDmg > 0 && !NihilNegationDef)
        {
            finalDamage += AstraDmg;
        }
        if (defender.Skills[0] == "Defense+2" && !NihilNegationAtk)
        {
            finalDamage -= 2;
        }
        if (attacker.rallied)
        {
            finalDamage++;
        }
        if (defender.rallied)
        {
            finalDamage--;
        }
        if (defender.danced == 2)
        {
            finalDamage--;
        }
        finalDamage += attacker.danced;
        if (finalDamage < 0 && battleCalc)
        {
            finalDamage = 0;
        }
        if (defender.Skills[1] == "Dragonskin" && defender.promoted && !NihilNegationAtk)
        {
            float dragonskinDamage = finalDamage;
            finalDamage = Mathf.CeilToInt(dragonskinDamage / 2f);
        }
        if (lethality && !NihilNegationDef)
        {
            finalDamage = 99;
        }
        if (greatShield && !NihilNegationAtk)
        {
            finalDamage = 0;
        }
        if (attacker.Skills[1] == "Sol" && attacker.promoted && !NihilNegationDef)
        {
            if (finalDamage > defender.Stats[0])
            {
                attacker.Heal(defender.Stats[0]);
            }
            else
            {
                attacker.Heal(finalDamage);
            }
        }
        return(finalDamage);
    }
示例#20
0
 internal void addPiece(BasePiece pieceBase)
 {
     this.IsEmptyBoard = (this.IsEmptyBoard && pieceBase.IsEmpty);
     _chessboard.Add(pieceBase);
 }
示例#21
0
    public void PreBattleCalc(BasePiece attacker, BasePiece defender, List <TextMeshProUGUI> ForecastTexts)
    {
        greatShield           = miracle = lethality = false;
        AstraDmg              = 0;
        ForecastTexts[0].text = attacker.Type[2];
        ForecastTexts[1].text = ("HP: " + attacker.Stats[0] + "/" + attacker.Stats[4]);
        ForecastTexts[2].text = ("Damage: " + attacker.Stats[1] + "-" + attacker.Stats[2]);
        int bonusDmg = DamageCalculator(attacker, defender, false);

        if (bonusDmg != 0)
        {
            ForecastTexts[3].gameObject.SetActive(true);
            //Enables/Disables Buff and Nerf Arrows
            if (bonusDmg < 0)
            {
                ForecastTexts[3].text = bonusDmg.ToString();
                ForecastTexts[3].transform.GetChild(0).gameObject.SetActive(false);
                ForecastTexts[3].transform.GetChild(1).gameObject.SetActive(true);
            }
            else
            {
                ForecastTexts[3].text = "+" + bonusDmg;
                ForecastTexts[3].transform.GetChild(0).gameObject.SetActive(true);
                ForecastTexts[3].transform.GetChild(1).gameObject.SetActive(false);
            }
        }
        else
        {
            ForecastTexts[3].gameObject.SetActive(false);
        }
        ForecastTexts[4].text = ("Hit Chance: " + (12 - defender.Stats[3]) + "/12");
        int bonusAvo = AvoidCalculator(attacker, defender, 0) * -1;

        if (bonusAvo != 0)
        {
            ForecastTexts[5].gameObject.SetActive(true);
            //Enables/Disables Buff and Nerf Arrows
            if (bonusAvo < 0)
            {
                ForecastTexts[5].text = bonusAvo.ToString();
                ForecastTexts[5].transform.GetChild(0).gameObject.SetActive(false);
                ForecastTexts[5].transform.GetChild(1).gameObject.SetActive(true);
            }
            else
            {
                ForecastTexts[5].text = "+" + bonusAvo;
                ForecastTexts[5].transform.GetChild(0).gameObject.SetActive(true);
                ForecastTexts[5].transform.GetChild(1).gameObject.SetActive(false);
            }
        }
        else
        {
            ForecastTexts[5].gameObject.SetActive(false);
        }
        //If the base skill of the unit is a combat skill, it is shown on the forecast window
        //For Archer, Wyvern Riders, and Mercenaries script checks if those skills are active
        ForecastTexts[6].text = "";
        if (NihilNegationDef == false)
        {
            if ((attacker.Type[1] == "Mercenary" && PreBattleMercenarySkills) ||
                (attacker.Type[1] == "Archer" && PreBattleArcherSkills) ||
                (attacker.Type[1] == "Wyvern Rider" && PreBattleTrample) || (attacker.CombatSkills[0] &&
                                                                             (attacker.Type[1] != "Mercenary" && attacker.Type[1] != "Archer" && attacker.Type[1] != "Wyvern Rider")))
            {
                ForecastTexts[6].text = attacker.Skills[0];
            }
        }
        //Same as above, but for promoted skills and Villagers instead of Wyvern Riders
        ForecastTexts[7].text = "";
        if (attacker.promoted && NihilNegationDef == false)
        {
            if ((attacker.Type[1] == "Mercenary" && PreBattleMercenarySkills) ||
                (attacker.Type[1] == "Archer" && PreBattleArcherSkills) ||
                (attacker.Type[0] == "Pawn" && PreBattleUnderdog) || (attacker.CombatSkills[1] &&
                                                                      (attacker.Type[1] != "Mercenary" && attacker.Type[1] != "Archer" && attacker.Type[0] != "Pawn")))
            {
                ForecastTexts[7].text = attacker.Skills[1];
            }
        }
    }
示例#22
0
 public static void SwapBase(BasePiece b, Player originalPlayer, Player newPlayer)
 {
     b.Reset(newPlayer);
     newPlayer.AddBase(b);
     originalPlayer.RemoveBase(b);
 }
示例#23
0
 public BasePiecePlacedEvent(BasePiece basePiece)
 {
     BasePiece = basePiece;
 }
示例#24
0
    public void PlacePieces(List <string> pieces)
    {
        mPieceManager.KillAllPieces();
        mPieceManager.mWhitePieces.Clear();
        mPieceManager.mBlackPieces.Clear();
        int  count         = 0;
        int  kingCount     = 0;
        bool whiteKingDead = true;
        bool blackKingDead = true;

        for (int i = 0; i < 8; i++)
        {
            for (int j = 0; j < 8; j++)
            {
                if (!pieces[count].Equals("empty"))
                {
                    string[] s = pieces[count].Split('|');

                    string key   = s[0];
                    string color = s[1];
                    if (color.Equals("RGBA(1.000, 1.000, 1.000, 1.000)"))
                    {
                        color = "White";
                    }
                    else
                    {
                        color = "Black";
                    }
                    Type      pieceType = mPieceLibrary[key];
                    BasePiece bp        = mPieceManager.CreatePiece(pieceType);
                    Color32   spriteColor;
                    if (key.Equals("Pawn"))
                    {
                        if (color.Equals("Black") && j != 6)
                        {
                            bp.mIsFirstMove = false;
                        }
                        else if (color.Equals("White") && j != 1)
                        {
                            bp.mIsFirstMove = false;
                        }
                    }
                    if (key.Equals("King"))
                    {
                        kingCount++;
                        if (color.Equals("Black"))
                        {
                            blackKingDead = false;
                        }
                        else if (color.Equals("White"))
                        {
                            whiteKingDead = false;
                        }
                    }
                    if (color.Equals("Black"))
                    {
                        spriteColor = new Color32(0, 0, 0, 255);
                        bp.Setup(Color.black, spriteColor, mPieceManager);
                        mPieceManager.mBlackPieces.Add(bp);
                    }
                    else
                    {
                        spriteColor = new Color32(255, 255, 255, 255);
                        bp.Setup(Color.white, spriteColor, mPieceManager);
                        mPieceManager.mWhitePieces.Add(bp);
                    }
                    bp.mCurrentCell  = mBoard.mAllCells[i, j];
                    bp.mOriginalCell = mBoard.mAllCells[i, j];
                    bp.mCurrentCell.mCurrentPiece = bp;
                    bp.transform.position         = mBoard.mAllCells[i, j].transform.position;
                    bp.gameObject.SetActive(true);
                    //mBoard.mAllCells[i, j].transform.position = bp.transform.position;
                }
                else
                {
                    mBoard.mAllCells[i, j].mCurrentPiece = null;
                }
                count++;
            }
        }
        if (kingCount < 2)
        {
            if (whiteKingDead)
            {
                info.text = "Black wins!";
            }
            else if (blackKingDead)
            {
                info.text = "White wins!";
            }
            p = "CLIENTSEND";
            if (IsHost())
            {
                cs.SendMessage();
            }
            else
            {
                cc.SendMessage();
            }
        }
    }
示例#25
0
 private void _destroyPiece(BasePiece piece)
 {
     Destroy(piece.gameObject);
 }
示例#26
0
 public void EnqueueBasePiecePlaced(BasePiece basePiece)
 {
     Log.Info("Enqueuing base piece to be placed id: " + basePiece.Id + " parentId: " + basePiece.ParentId.OrElse(null));
     Enqueue(new BasePiecePlacedEvent(basePiece));
 }
示例#27
0
 public void AtkTarget(BasePiece target, int dmg)
 {
     _target = target;
     _dmg    = dmg;
 }
示例#28
0
 public void AddBase(BasePiece b)
 {
     bases.Add(b);
 }
示例#29
0
        private void BasePieceTest(BasePiece basePiece, BasePiece basePieceAfter, int serializerIndex)
        {
            Assert.AreEqual(basePiece.Id, basePieceAfter.Id, $"BasePiece.Id is not equal while using {serverSerializers[serializerIndex]}.");
            Assert.AreEqual(basePiece.ItemPosition, basePieceAfter.ItemPosition, $"BasePiece.ItemPosition is not equal while using {serverSerializers[serializerIndex]}.");
            Assert.AreEqual(basePiece.Rotation, basePieceAfter.Rotation, $"BasePiece.Rotation is not equal while using {serverSerializers[serializerIndex]}.");
            Assert.AreEqual(basePiece.TechType, basePieceAfter.TechType, $"BasePiece.TechType is not equal while using {serverSerializers[serializerIndex]}.");
            Assert.AreEqual(basePiece.ParentId, basePieceAfter.ParentId, $"BasePiece.ParentId is not equal while using {serverSerializers[serializerIndex]}.");
            Assert.AreEqual(basePiece.CameraPosition, basePieceAfter.CameraPosition, $"BasePiece.CameraPosition is not equal while using {serverSerializers[serializerIndex]}.");
            Assert.AreEqual(basePiece.CameraRotation, basePieceAfter.CameraRotation, $"BasePiece.CameraRotation is not equal while using {serverSerializers[serializerIndex]}.");
            Assert.AreEqual(basePiece.ConstructionAmount, basePieceAfter.ConstructionAmount, $"BasePiece.ConstructionAmount is not equal while using {serverSerializers[serializerIndex]}.");
            Assert.AreEqual(basePiece.ConstructionCompleted, basePieceAfter.ConstructionCompleted, $"BasePiece.ConstructionCompleted is not equal while using {serverSerializers[serializerIndex]}.");
            Assert.AreEqual(basePiece.IsFurniture, basePieceAfter.IsFurniture, $"BasePiece.IsFurniture is not equal while using {serverSerializers[serializerIndex]}.");
            Assert.AreEqual(basePiece.BaseId, basePieceAfter.BaseId, $"BasePiece.BaseId is not equal while using {serverSerializers[serializerIndex]}.");
            Assert.AreEqual(basePiece.BuildIndex, basePieceAfter.BuildIndex, $"BasePiece.BuildIndex is not equal while using {serverSerializers[serializerIndex]}.");

            switch (basePiece.RotationMetadata.Value)
            {
            case AnchoredFaceRotationMetadata anchoredMetadata when basePieceAfter.RotationMetadata.Value is AnchoredFaceRotationMetadata anchoredMetadataAfter:
                Assert.AreEqual(anchoredMetadata.Cell, anchoredMetadataAfter.Cell, $"BasePiece.RotationMetadata.Cell (AnchoredFaceRotationMetadata) is not equal while using {serverSerializers[serializerIndex]}.");
                Assert.AreEqual(anchoredMetadata.Direction, anchoredMetadataAfter.Direction, $"BasePiece.RotationMetadata.Direction (AnchoredFaceRotationMetadata) is not equal while using {serverSerializers[serializerIndex]}.");
                Assert.AreEqual(anchoredMetadata.FaceType, anchoredMetadataAfter.FaceType, $"BasePiece.RotationMetadata.FaceType (AnchoredFaceRotationMetadata) is not equal while using {serverSerializers[serializerIndex]}.");
                break;

            case BaseModuleRotationMetadata baseModuleMetadata when basePieceAfter.RotationMetadata.Value is BaseModuleRotationMetadata baseModuleMetadataAfter:
                Assert.AreEqual(baseModuleMetadata.Cell, baseModuleMetadataAfter.Cell, $"BasePiece.RotationMetadata.Cell (BaseModuleRotationMetadata) is not equal while using {serverSerializers[serializerIndex]}.");
                Assert.AreEqual(baseModuleMetadata.Direction, baseModuleMetadataAfter.Direction, $"BasePiece.RotationMetadata.Direction (BaseModuleRotationMetadata) is not equal while using {serverSerializers[serializerIndex]}.");
                break;

            case CorridorRotationMetadata corridorMetadata when basePieceAfter.RotationMetadata.Value is CorridorRotationMetadata corridorMetadataAfter:
                Assert.AreEqual(corridorMetadata.Rotation, corridorMetadataAfter.Rotation, $"BasePiece.RotationMetadata.Rotation (CorridorRotationMetadata) is not equal while using {serverSerializers[serializerIndex]}.");
                break;

            case MapRoomRotationMetadata mapRoomMetadata when basePieceAfter.RotationMetadata.Value is MapRoomRotationMetadata mapRoomMetadataAfter:
                Assert.AreEqual(mapRoomMetadata.CellType, mapRoomMetadataAfter.CellType, $"BasePiece.RotationMetadata.CellType (MapRoomRotationMetadata) is not equal while using {serverSerializers[serializerIndex]}.");
                Assert.AreEqual(mapRoomMetadata.ConnectionMask, mapRoomMetadataAfter.ConnectionMask, $"BasePiece.RotationMetadata.ConnectionMask (MapRoomRotationMetadata) is not equal while using {serverSerializers[serializerIndex]}.");
                break;

            case null when basePieceAfter.RotationMetadata.Value is null:
                break;

            default:
                Assert.Fail($"BasePiece.RotationMetadata is not equal while using {serverSerializers[serializerIndex]}.");
                break;
            }

            switch (basePiece.Metadata.Value)
            {
            case SignMetadata signMetadata when basePieceAfter.Metadata.Value is SignMetadata signMetadataAfter:
                Assert.AreEqual(signMetadata.Text, signMetadataAfter.Text, $"BasePiece.Metadata.Text (SignMetadata) is not equal while using {serverSerializers[serializerIndex]}.");
                Assert.AreEqual(signMetadata.ColorIndex, signMetadataAfter.ColorIndex, $"BasePiece.Metadata.ColorIndex (SignMetadata) is not equal while using {serverSerializers[serializerIndex]}.");
                Assert.AreEqual(signMetadata.ScaleIndex, signMetadataAfter.ScaleIndex, $"BasePiece.Metadata.ScaleIndex (SignMetadata) is not equal while using {serverSerializers[serializerIndex]}.");
                Assert.IsTrue(signMetadata.Elements.SequenceEqual(signMetadataAfter.Elements), $"BasePiece.Metadata.Elements (SignMetadata) is not equal while using {serverSerializers[serializerIndex]}.");
                Assert.AreEqual(signMetadata.Background, signMetadataAfter.Background, $"BasePiece.Metadata.Background (SignMetadata) is not equal while using {serverSerializers[serializerIndex]}.");
                break;

            case null when basePieceAfter.Metadata.Value is null:
                break;

            default:
                Assert.Fail($"BasePiece.Metadata is not equal while using {serverSerializers[serializerIndex]}.");
                break;
            }
        }
示例#30
0
 void Awake()
 {
     _piece = GetComponent <BasePiece>();
 }