예제 #1
0
    /*if there are lobsters defending, return a list of defend lobsters,
     * if there are only attacking lobsters, return a list of lobsters,
     * otherwise, return null to indicate there is no lobster to attack*/
    public List <Lobster> GetAttackableLobsters()
    {
        List <Lobster> result = new List <Lobster>();

        //get all defense lobsters
        foreach (GameObject spot in spots)
        {
            FloorSpot floorSpot = spot.GetComponent <FloorSpot>();
            //when there is defending lobster in play
            if (floorSpot.GetCardInPlay() != null && floorSpot.GetCardType() == CardType.Lobster &&
                floorSpot.GetCardInPlay().GetComponent <Lobster>().GetState() == LobsterState.Defence)
            {
                result.Add(floorSpot.GetCardInPlay().GetComponent <Lobster>());
            }
        }
        //if the list is not empty, we have defending lobsters, return them
        if (result.Count > 0)
        {
            return(result);
        }
        //do not have defending lobsters, get all lobsters
        foreach (GameObject spot in spots)
        {
            FloorSpot floorSpot = spot.GetComponent <FloorSpot>();
            //when there is defending lobster in play
            if (floorSpot.GetCardInPlay() != null && floorSpot.GetCardType() == CardType.Lobster)
            {
                result.Add(floorSpot.GetCardInPlay().GetComponent <Lobster>());
            }
        }
        //return the result of all lobsters on the floor
        return(result);
    }
예제 #2
0
 private void UnSelectSpot(FloorSpot spot)
 {
     selectedSpots.Remove(spot);
     SetGlobalScale(spot.GetCardInPlay(), SystemManager.cardNormalScale);
     levelSum -= spot.GetCardData().level;
     UpdateText();
 }
예제 #3
0
 private void SelectSpot(FloorSpot spot)
 {
     //only lobsters who have not attacked can be used as material
     if (spot.GetCardInPlay() && spot.GetCardInPlay().GetComponent <Lobster>() && spot.GetCardInPlay().GetComponent <Lobster>().canAttack)
     {
         selectedSpots.Add(spot);
         SetGlobalScale(spot.GetCardInPlay(), SystemManager.cardSelectedScale);
         levelSum += spot.GetCardData().level;
         UpdateText();
     }
 }
예제 #4
0
 //get the level needed and start selection
 public void StartMaterialSelection(GameObject card, GameObject spot)
 {
     targetSpot = spot;
     this.card  = card;
     gameObject.SetActive(true);
     levelSum      = 0;
     neededLevel   = card.GetComponent <CardStats>().cardData.level - 1;
     selectedSpots = new List <FloorSpot>(3);
     //hide the moveMenu of all lobsters
     foreach (GameObject oneSpot in playerFloor.GetComponent <Floor>().spots)
     {
         FloorSpot floorSpot = oneSpot.GetComponent <FloorSpot>();
         //when this spot has lobster
         if (floorSpot.GetCardInPlay() && floorSpot.GetCardInPlay().GetComponent <Lobster>())
         {
             floorSpot.GetCardInPlay().GetComponent <Lobster>().CloseMoveMenuImmediately();
         }
     }
     UpdateText();
     checking = true;
 }
예제 #5
0
 private void CheckMaterialSelection()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Vector2    cameraPos  = mainCamera.ScreenToWorldPoint(Input.mousePosition);
         GameObject spotObject = playerFloor.GetComponent <Floor>().SpotTouched(cameraPos);
         //when touched sth
         if (spotObject)
         {
             FloorSpot spot = spotObject.GetComponent <FloorSpot>();
             //see if player is selecting a new spot or unselected one
             if (selectedSpots.Contains(spot))
             {
                 UnSelectSpot(spot);
             }
             else
             {
                 SelectSpot(spot);
             }
         }
     }
 }