Beispiel #1
0
    public void SetInstructionCardSelectedState(InstructionCard ic, int team, PlayerController player)
    {
        bool selectedState = false;

        if (team == 1)
        {
            foreach (PlayerController pc in team1)
            {
                if (pc.ControllerId != player.ControllerId)
                {
                    if (pc.currentSelectedRow == ic.currentInstructionCard.rowId &&
                        pc.currentSelectedColumn == ic.currentInstructionCard.columnId)
                    {
                        selectedState = true;
                    }
                }
            }
        }
        else
        {
            foreach (PlayerController pc in team2)
            {
                if (pc.ControllerId != player.ControllerId)
                {
                    if (pc.currentSelectedRow == ic.currentInstructionCard.rowId &&
                        pc.currentSelectedColumn == ic.currentInstructionCard.columnId)
                    {
                        selectedState = true;
                    }
                }
            }
        }

        ic.isSelected = selectedState;
    }
Beispiel #2
0
    private void MoveCanvasPlayerDown(bool checkOtherColumn = false)
    {
        int             smallestRowDifference = 99999;
        InstructionCard icToMoveTo            = null;

        foreach (InstructionCard ic in currentInstructionCards)
        {
            if (!ic.IsComplete && ic.currentInstructionCard.rowId > currentSelectedRow && Mathf.Abs(currentSelectedRow - ic.currentInstructionCard.rowId) < smallestRowDifference)
            {
                if (checkOtherColumn)
                {
                    icToMoveTo            = ic;
                    smallestRowDifference = Mathf.Abs(currentSelectedRow - ic.currentInstructionCard.rowId);
                }
                else if (ic.currentInstructionCard.columnId == currentSelectedColumn)
                {
                    icToMoveTo            = ic;
                    smallestRowDifference = Mathf.Abs(currentSelectedRow - ic.currentInstructionCard.rowId);
                }
            }
        }

        if (icToMoveTo)
        {
            MoveToNewInstructionCard(icToMoveTo);
        }
        else
        {
            if (!checkOtherColumn)
            {
                MoveCanvasPlayerUp(true);
            }
        }
    }
Beispiel #3
0
 public void GenerateInstructionCards(int cardCount)
 {
     for (int i = 0; i < cardCount; i++)
     {
         GameObject      cardPrefab             = Resources.Load("InstructionCard") as GameObject;
         GameObject      card                   = GameObject.Instantiate(cardPrefab, GameManager.instance.GameCanvas.transform);
         InstructionCard currentInstructionCard = card.GetComponent <InstructionCard>();
         currentInstructionCard.Setup(GetRepairType(), (int)UnityEngine.Random.Range(GameManager.instance.RoundData[_roundNumber - 1].MinRepairCount, GameManager.instance.RoundData[_roundNumber - 1].MaxRepairCount), _teamId);
         currentInstructionCard.OnCardComplete += CheckRoundComplete;
         _intructions.Add(currentInstructionCard);
     }
 }
Beispiel #4
0
 public void PopulateCard(InstructionCard card)
 {
     foreach (Repair r in card.Repairs)
     {
         GameObject buttonIconResource = Resources.Load("ButtonIcon") as GameObject;
         GameObject buttonIcon         = GameObject.Instantiate(buttonIconResource, repairRow);
         ButtonIcon bi = buttonIcon.GetComponent <ButtonIcon>();
         foreach (KeyValuePair <string, Enums.RepairType> keyValuePair in r.repairRequirements)
         {
             bi.SetImage(keyValuePair.Key);
         }
     }
 }
Beispiel #5
0
    public void DisableCard()
    {
        ResetProgress();

        foreach (Transform child in repairRow)
        {
            GameObject.Destroy(child.gameObject);
        }


        _inUse = false;
        activeObject.SetActive(false);
        disabledObject.SetActive(true);
        instructionCard = null;
    }
Beispiel #6
0
    private void MoveToNewInstructionCard(InstructionCard ic)
    {
        canMoveCanvasPlayer = false;
        if (currentlySelectedInstructionCard)
        {
            GameManager.instance.SetInstructionCardSelectedState(currentlySelectedInstructionCard, _teamId, this);
        }

        currentlySelectedInstructionCard            = ic;
        currentlySelectedInstructionCard.isSelected = true;

        canvasPlayer.transform.position = new Vector3(ic.currentInstructionCard.transform.position.x - (canvasPlayer.GetComponent <RepairAvatar>().isPlayer2 ? -1.1f : 1.1f), ic.currentInstructionCard.transform.position.y, ic.currentInstructionCard.transform.position.z);
        currentSelectedRow    = ic.currentInstructionCard.rowId;
        currentSelectedColumn = ic.currentInstructionCard.columnId;
        canvasPlayer.GetComponent <RepairAvatar>().animator.SetTrigger("NewCard");
        StartCoroutine(ResetMoveCanvasPlayer());
    }
Beispiel #7
0
    private void MoveCanvasPlayerRight()
    {
        int             smallestRowDifference = 99999;
        InstructionCard icToMoveTo            = null;

        foreach (InstructionCard ic in currentInstructionCards)
        {
            if (!ic.IsComplete && ic.currentInstructionCard.columnId > currentSelectedColumn && Mathf.Abs(currentSelectedRow - ic.currentInstructionCard.rowId) < smallestRowDifference)
            {
                icToMoveTo            = ic;
                smallestRowDifference = Mathf.Abs(currentSelectedRow - ic.currentInstructionCard.rowId);
            }
        }

        if (icToMoveTo)
        {
            MoveToNewInstructionCard(icToMoveTo);
        }
    }
Beispiel #8
0
    public void ActivateCard(InstructionCard card)
    {
        _inUse = true;
        activeObject.SetActive(true);
        disabledObject.SetActive(false);
        instructionCard = card;
        animator.SetTrigger("Show");

        if (card.InstructionType == Enums.InstructionType.Solo)
        {
            instructionTypeImage.sprite = soloInstruction;
        }
        else
        {
            instructionTypeImage.sprite = teamInstruction;
        }

        PopulateCard(card);
    }