Exemplo n.º 1
0
    public void InitBattle(CombatantBoard player, CombatantBoard opponent)
    {
        playerBoard  = player;
        playerHealth = playerBoard.GetComponent <Health>();
        playerBoard.SetBoardTeamID(0);

        opponentBoard  = opponent;
        opponentHealth = opponentBoard.GetComponent <Health>();
        opponentBoard.SetBoardTeamID(1);
        opponentBoard.MirrorBoard();

        /// grant Initial Move tokens
        MoveCounter playerMoveCounter = playerBoard.GetComponentInChildren <MoveCounter>();

        if (playerMoveCounter != null)
        {
            playerMoveCounter.AddMoveToken(1);
        }
        MoveCounter opponentMoveCounter = opponentBoard.GetComponentInChildren <MoveCounter>();

        if (opponentMoveCounter != null)
        {
            opponentMoveCounter.AddMoveToken(1);
        }

        /// begin game with initial move
        if (warmupPanel == null)
        {
            warmupPanel = FindObjectOfType <WarmupPanel>();
        }
        warmupCoroutine = Warmup("INITIAL MOVE", initialWarmupTime);
        StartCoroutine(warmupCoroutine);
    }
Exemplo n.º 2
0
 void Awake()
 {
     board         = GetComponent <CombatantBoard>();
     cellLibrary   = FindObjectOfType <CellLibrary>();
     cellList      = new List <CellData>();
     boardSlotList = new List <CellSlot>();
     occupiedSlots = new List <CellSlot>();
 }
Exemplo n.º 3
0
    private Save CreatePlayerBoardSave()
    {
        Save           save          = new Save();
        List <int>     playerCellIDs = new List <int>();
        CombatantBoard playerBoard   = null;

        CombatantBoard[] boards = FindObjectsOfType <CombatantBoard>();
        foreach (CombatantBoard cb in boards)
        {
            if (cb.tag == "Player")
            {
                playerBoard = cb;
                break;
            }
        }
        if (playerBoard != null)
        {
            List <CellSlot> boardSlots = new List <CellSlot>();
            boardSlots = playerBoard.GetSlots();
            int numLiveCells = 0;
            for (int i = 0; i < boardSlots.Count; i++)
            {
                CellData cd = null;
                if (boardSlots[i].GetCell() != null)
                {
                    cd = boardSlots[i].GetCell().GetCellData();
                }
                if (cd != null)
                {
                    playerCells.Add(cd);
                    if (playerCellIDs.Count > i)
                    {
                        playerCellIDs[i] = cd.saveID;
                    }
                    else
                    {
                        playerCellIDs.Add(cd.saveID);
                    }
                    numLiveCells++;
                }
                else
                {
                    if (playerCellIDs.Count > i)
                    {
                        playerCellIDs[i] = -1;
                    }
                    else
                    {
                        playerCellIDs.Add(-1);
                    }
                }
            }
        }

        save.playerCellIDs = playerCellIDs;
        return(save);
    }
Exemplo n.º 4
0
 void Start()
 {
     playerBoard           = GetComponentInChildren <CombatantBoard>();
     removeCellCanvasGroup = removeCellPanel.GetComponent <CanvasGroup>();
     EnableCancelButton(false);
     EnableRemovePanel(false);
     game = FindObjectOfType <Game>();
     game.LoadGame();
 }
Exemplo n.º 5
0
    public void FinishMoveToSlot()
    {
        CombatantBoard myBoard = parentRectTransform.parent.GetComponentInParent <CombatantBoard>();

        if (myBoard != null)
        {
            bool      bGoodMove        = false;
            Transform closestTransform = myBoard.GetClosestSlotTo(transform.position);
            if (closestTransform != null)
            {
                CellSlot closestSlot = closestTransform.GetComponent <CellSlot>();
                if (closestSlot != cellSlot)
                {
                    transform.SetParent(closestTransform);
                    transform.localPosition = Vector3.zero;
                    transform.localScale    = Vector3.one;

                    //if ((moveOriginSlot != null) && (moveOriginSlot.GetCell() != null))
                    //{
                    //	CellData cellData = moveOriginSlot.GetCell().GetCellData();
                    //	if (cellData != null)
                    //		combatCell.LoadCellData(cellData);
                    //}

                    bGoodMove = true;
                    cellSlot  = closestSlot;
                    cellSlot.LoadCell(combatCell, movingCellData, false);
                    combatCell.SetSlot(cellSlot);

                    /// On Move Ability
                    if ((combatCell != null) && (combatCell.GetCellData() != null) &&
                        (combatCell.GetCellData().bOnMoveAbility))
                    {
                        combatCell.GetCellData().OnMoveAbility(cellSlot);
                    }
                }
                else
                {
                    /// move ended up at origin
                    transform.SetParent(cellSlot.transform);
                    transform.localPosition = Vector3.zero;
                    transform.localScale    = Vector3.one;
                }
            }

            if (bGoodMove)
            {
                if (moveCounter != null)
                {
                    moveCounter.SpendMoveToken(1);
                }

                moveOriginSlot.ClearCell(false);
            }
        }
    }
Exemplo n.º 6
0
 void Awake()
 {
     colorBlinker = GetComponent <ColorBlinker>();
     boardEditor  = FindObjectOfType <BoardEditor>();
     cam          = Camera.main;
     button       = GetComponent <Button>();
     slotSprite   = image.sprite;
     slotColor    = image.color;
     ShowHighlight(false);
     board = transform.parent.parent.GetComponent <CombatantBoard>();
     SetInteractible(false);
 }
Exemplo n.º 7
0
    public void GenerateBoard()
    {
        if (cellLibrary == null)
        {
            cellLibrary = FindObjectOfType <CellLibrary>();
        }
        if (board == null)
        {
            board = GetComponent <CombatantBoard>();
        }

        boardSlotList = board.GetSlots();
        numCellTypes  = cellLibrary.allCells.Length;
        numBoardSlots = boardSlotList.Count;

        while ((cells < cellCount) && (cellValue < numBoardSlots) && (tries < 100))
        {
            /// first row guaranteed
            for (int i = 0; i < board.boardColumnCount; i++)
            {
                CellSlot cs = boardSlotList[i];
                NewCell();
            }

            /// remaining cells randomly
            foreach (CellSlot cs in boardSlotList)
            {
                if ((cs.GetCell() == null) ||
                    ((cs.GetCell() != null) && (cs.GetCell().GetCellData() != null)))
                {
                    if ((Random.Range(0f, 1f) > 0.3f) && (cells < cellCount))
                    {
                        NewCell();
                    }
                    else
                    {
                        if (cells < cellCount)
                        {
                            cellList.Add(null);
                        }
                    }
                }
            }
            tries++;
        }

        board.LoadBoard(cellList);
    }
Exemplo n.º 8
0
    /// Soap has 2 60% chances to create a copy when eliminated
    public override void OnCellDiedAbility(CombatantCell myCell)
    {
        base.OnCellDiedAbility(myCell);

        if (myCell != null)
        {
            CellSlot cellSlot = myCell.GetSlot();
            if (cellSlot != null)
            {
                List <CellSlot> neighborSlots = new List <CellSlot>();
                neighborSlots       = cellSlot.GetNeighborSlots();
                numFragmentsDropped = 0;

                foreach (CellSlot cs in neighborSlots)
                {
                    float randomFragmentShot = Random.Range(0f, 1f);

                    if (((cs.GetCell() == null) || ((cs.GetCell() != null) && (cs.GetCell().GetCellData() == null))) &&
                        (randomFragmentShot <= fragmentDropRate))
                    {
                        CombatantBoard board = cs.GetBoard();
                        board.SpawnCombatCell(this, cs);
                        numFragmentsDropped++;
                    }

                    if (numFragmentsDropped >= potentialFragmentsOnCellDied)
                    {
                        break;
                    }
                }
            }

            myCell.ShowCanvasGroup(false);
            Destroy(myCell, 0.5f);
        }
    }