Example #1
0
 public void SetAttributes(TacticAttributes attributes, int ownerID = -1)
 {
     if (attributes == null)
     {
         return;
     }
     piece                = null;
     tactic               = attributes;
     trap                 = null;
     nameText.text        = attributes.Name;
     cardName             = attributes.Name;
     description          = attributes.description;
     descriptionText.text = attributes.description;
     cost                 = attributes.oreCost;
     costText.text        = attributes.oreCost.ToString();
     costImage.SetActive(true);
     healthImage.SetActive(false);
     coinImage.SetActive(true);
     health        = attributes.goldCost;
     coinText.text = attributes.goldCost.ToString();
     image.sprite  = attributes.image;
     type          = "Tactic";
     typeText.text = type;
     SetOwner(ownerID);
 }
Example #2
0
    public static void ResumePiece(Piece piece)
    {
        PieceAttributes attributes = Database.FindPieceAttributes(piece.GetName());

        piece.oreCost = attributes.oreCost;
        piece.health  = piece.collection.health;
        piece.freeze  = 0;
    }
Example #3
0
 public void OnEndDrag(PointerEventData eventData)
 {
     if (!dragBegins)
     {
         return;
     }
     dragBegins = false;
     if (!infoCard.GetComponent <CardInfo>().IsStandard())
     {
         cardImage.GetComponent <Image>().sprite = null;
         CardInfo   newCard = infoCard.GetComponent <CardInfo>();
         GameObject find    = GameObject.Find(FindLoc(Input.mousePosition).ToString());
         if (find != null)
         {
             Transform oldObject    = find.transform;
             Image     oldCardImage = oldObject.Find("CardImage").GetComponent <Image>();
             if (oldCardImage.sprite != null)
             {
                 // switch
                 PieceAttributes attributes = boardInfo.attributesDict[oldObject.name];
                 if (attributes.type == newCard.GetCardType())
                 {
                     boardInfo.SetCard(attributes, new Location(parent.name));
                     cardImage.GetComponent <Image>().sprite = attributes.image;
                     parent = oldObject;
                     boardInfo.SetCard(newCard.piece, new Location(parent.name));
                     oldCardImage.sprite = newCard.piece.image;
                 }
                 else
                 {
                     // Show Animation: Can't Switch
                     StartCoroutine(ShowCantSwitch());
                     cardImage.GetComponent <Image>().sprite = infoCard.GetComponent <CardInfo>().piece.image;
                 }
             }
             else
             {
                 // Drag to an empty spot and resume.
                 cardImage.GetComponent <Image>().sprite = infoCard.GetComponent <CardInfo>().piece.image;
             }
         }
         else
         {
             // Drag outside the board.
             string cardType = newCard.GetCardType();
             collectionManager.AddCollection(new Collection(newCard.piece));
             boardInfo.SetStandardCard(cardType, new Location(parent.name));
             collectionManager.RemoveCollection(Collection.StandardCollection(cardType));
             collectionManager.ShowCurrentPage();
             cardImage.sprite = Database.standardAttributes["Standard " + cardType].image;
         }
     }
     EnableImage(cardImage);
     infoCard.SetActive(false);
 }
Example #4
0
 public Collection(PieceAttributes attributes, int Count = 1, int Health = 0)
 {
     name   = attributes.Name;
     type   = attributes.type;
     count  = Count;
     health = Health;
     if (Health == 0)
     {
         health = attributes.health;
     }
 }
Example #5
0
 private void FindAttributes()
 {
     //WriteDirectories();
     ReadDirectories();
     foreach (string type in loadType)
     {
         foreach (string folder in directories[type])
         {
             if (type == "Standard Piece")
             {
                 PieceAttributes attributes = LoadPieceAttributes(folder);
                 standardAttributes.Add(attributes.Name, attributes);
             }
             else if (type == "Piece")
             {
                 PieceAttributes attributes = LoadPieceAttributes(folder);
                 pieces.Add(attributes.Name, attributes);
                 pieceList.Add(attributes.Name);
                 pieceListDict[attributes.type].Add(attributes.Name);
             }
             else if (type == "Tactic")
             {
                 TacticAttributes attributes = LoadTacticAttributes(folder);
                 tactics.Add(attributes.Name, attributes);
                 tacticList.Add(attributes.Name);
             }
             else if (type == "Board")
             {
                 BoardAttributes attributes = LoadBoardAttributes(folder);
                 boards.Add(attributes.Name, attributes);
                 boardList.Add(attributes.Name);
             }
             else if (type == "Trap")
             {
                 TrapAttributes attributes = LoadTrapAttributes(folder);
                 traps.Add(attributes.Name, attributes);
                 trapList.Add(attributes.Name);
             }
             else if (type == "Contract")
             {
                 ContractAttributes attributes = LoadContractAttributes(folder);
                 contracts.Add(attributes.Name, attributes);
                 contractList.Add(attributes.Name);
             }
             else if (type == "Mission")
             {
                 MissionAttributes attributes = LoadMissionAttributes(folder);
                 missions.Add(attributes.Name, attributes);
                 missionList.Add(attributes.Name);
             }
         }
     }
 }
Example #6
0
 public void Clear()
 {
     piece                = null;
     tactic               = null;
     nameText.text        = "Name";
     descriptionText.text = "Description";
     costText.text        = "0";
     healthText.text      = "0";
     healthText.color     = Color.white;
     coinText.text        = "0";
     image.sprite         = null;
     cardName             = type = description = "";
     ownerID              = -1;
 }
Example #7
0
 public void Setup(Piece piece, bool original)
 {
     pieceAttributes = Database.FindPieceAttributes(piece.GetName());
     trigger         = Instantiate(pieceAttributes.trigger);
     SetPiece(piece);
     GetComponentInChildren <Image>().sprite = pieceAttributes.image;
     if (piece.IsAlly())
     {
         GetComponent <Renderer>().material = red;
     }
     else
     {
         GetComponent <Renderer>().material = black;
     }
 }
Example #8
0
    public void SetCards()
    {
        Login.user.ChangeContracts(targetContract.name, -contractCount, false);
        List <string> types = Database.FindContractAttributes(targetContract.name).cardTypes;

        for (int i = 0; i < contractCount * 5; i++)
        {
            string     type = types[Random.Range(0, types.Count)];
            Collection collection;
            if (type == "Tactic")
            {
                string           tactic     = Database.tacticList[Random.Range(0, Database.tacticList.Count)];
                TacticAttributes attributes = Database.FindTacticAttributes(tactic);
                collection = new Collection(attributes);
                cardView.transform.Find("Card" + i.ToString()).GetComponent <CardInfo>().SetAttributes(collection);
            }
            else
            {
                int             luck       = Random.Range(0, 100);
                List <string>   pieces     = Database.pieceListDict[type];
                string          piece      = pieces[Random.Range(0, pieces.Count)];
                PieceAttributes attributes = Database.FindPieceAttributes(piece);
                collection = new Collection(attributes);
                if (luck > 85)
                {
                    collection.health += (int)Mathf.Ceil(collection.health * 0.1f);
                }
                if (luck > 90)
                {
                    collection.health += (int)Mathf.Ceil(collection.health * 0.1f);
                }
                if (luck > 95)
                {
                    collection.health += (int)Mathf.Ceil(collection.health * 0.1f);
                }
                CardInfo cardInfo = cardView.transform.Find("Card" + i.ToString()).GetComponent <CardInfo>();
                cardInfo.SetAttributes(attributes);
                cardInfo.SetHealth(collection.health);
            }
            Login.user.AddCollection(collection, false);
        }
        Login.user.Upload();
        contractCount = 0;
    }
Example #9
0
 public void Setup(Collection collection, Location loc, int ownerID, bool original)
 {
     pieceAttributes = Database.FindPieceAttributes(collection.name);
     if (pieceAttributes.trigger == null)
     {
         Debug.Log(pieceAttributes.Name);
     }
     trigger = Instantiate(pieceAttributes.trigger);
     SetPiece(new Piece(collection, loc, pieceAttributes.oreCost, ownerID, original));
     GetComponentInChildren <Image>().sprite = pieceAttributes.image;
     if (piece.IsAlly())
     {
         GetComponent <Renderer>().material = red;
     }
     else
     {
         GetComponent <Renderer>().material = black;
     }
 }
Example #10
0
 public Collection(string Name, string Type, int Count = 1, int Health = 0)
 {
     name   = Name;
     type   = Type;
     count  = Count;
     health = Health;
     if (Type == "Tactic")
     {
         TacticAttributes attributes = Database.FindTacticAttributes(Name);
         health = attributes.goldCost;
     }
     else if (!Name.StartsWith("Standard "))
     {
         PieceAttributes attributes = Database.FindPieceAttributes(Name);
         if (Health == 0)
         {
             health = attributes.health;
         }
     }
 }
Example #11
0
 public void SetAttributes(TrapAttributes attributes, int ownerID = -1)
 {
     if (attributes == null)
     {
         return;
     }
     piece                = null;
     tactic               = null;
     trap                 = attributes;
     nameText.text        = attributes.Name;
     cardName             = attributes.Name;
     description          = attributes.description;
     descriptionText.text = attributes.description;
     costImage.SetActive(false);
     healthImage.SetActive(false);
     coinImage.SetActive(false);
     image.sprite  = attributes.image;
     type          = "Trap";
     typeText.text = type;
     SetOwner(ownerID);
 }
Example #12
0
 public void SetCard(PieceAttributes attributes, Location location)
 {
     cardLocations[location]             = new Collection(attributes.Name, attributes.type, 1, attributes.health);
     attributesDict[location.ToString()] = attributes;
 }