Ejemplo n.º 1
0
    public void Setup(EntitiesDatabaseSO.EntityData myData)
    {
        name.text = myData.name;
        cost.text = myData.cost.ToString();

        this.myData = myData;
    }
Ejemplo n.º 2
0
    public void OnCardClick(UICard card, EntitiesDatabaseSO.EntityData cardData)
    {
        //We should check if we have the money!
        if (PlayerData.Instance.CanAfford(cardData.cost))
        {
            if (cardData.name.Equals("Avatar"))
            {
            }
            //We should check if we can actually place that card, some cards have requirements other than cost.
            if (!GameManager.Instance.checkTreeRequirement(cardData.treeRequirement))
            {
                Debug.Log("You need at least " + cardData.treeRequirement + " trees conquered!");
                return;
            }

            //check if we have builders
            if (cardData.isBuilding)
            {
                if (!GameManager.Instance.CheckBuilders(GameManager.Instance.myTeam))
                {
                    Debug.Log("You need at least 1 builder in your board!");
                    return;
                }
            }

            PlayerData.Instance.SpendMoney(cardData.cost);
            //card.gameObject.SetActive(false);
            GameManager.Instance.OnEntityBought(cardData);
        }
    }
Ejemplo n.º 3
0
    public void Setup(EntitiesDatabaseSO.EntityData myData, UIShop shopRef)
    {
        icon.sprite = myData.icon;
        name.text   = myData.name;
        cost.text   = myData.cost.ToString();

        this.myData  = myData;
        this.shopRef = shopRef;
    }
Ejemplo n.º 4
0
    public void OnEntityBought(EntitiesDatabaseSO.EntityData entityData)
    {
        BaseEntity newEntity = Instantiate(entityData.prefab, team1Parent);

        newEntity.gameObject.name = entityData.name;
        team1Entities.Add(newEntity);

        newEntity.Setup(Team.Team1, GridManager.Instance.GetFreeNode(Team.Team1));
    }
Ejemplo n.º 5
0
 public void OnCardClick(UICard card, EntitiesDatabaseSO.EntityData cardData)
 {
     //We should check if we have the money!
     if (PlayerData.Instance.CanAfford(cardData.cost))
     {
         PlayerData.Instance.SpendMoney(cardData.cost);
         card.gameObject.SetActive(false);
         GameManager.Instance.OnEntityBought(cardData);
     }
 }
Ejemplo n.º 6
0
    //QUALE ENTITY SPAWNARE
    public void SpawnEnemy(string name, int nodeIndex)
    {
        foreach (EntitiesDatabaseSO.EntityData data in database.allEntities)
        {
            if (data.name.Equals(name))
            {
                entityData = data;
            }
        }

        BaseEntity newEntity = Instantiate(entityData.prefab, parent);

        newEntity.GetComponent <Dragger>().enabled = false;

        newEntity.gameObject.name = entityData.name;
        newEntity.movement        = entityData.movement;
        newEntity.baseHealth      = entityData.health;
        newEntity.baseDamage      = entityData.damage;
        newEntity.isBuilding      = entityData.isBuilding;

        GameManager.Instance.GetEntitiesAgainst(GameManager.Instance.myTeam).Add(newEntity);

        Node node = GridManager.Instance.GetNodeAtIndex(nodeIndex);

        if (node.IsOccupied)
        {
            foreach (BaseEntity entity in GameManager.Instance.GetEntitiesAgainst(GameManager.Instance.myTeam))
            {
                if (entity.CurrentNode == node)
                {
                    entity.TakeDamage(entity.baseHealth);
                    entity.RedParticlesPlay();
                    entity.HideEntity();
                    break;
                }
            }
        }

        newEntity.SetCurrentNode(node);
        newEntity.SetStartingNode(node);
        GridManager.Instance.GetNodeAtIndex(nodeIndex).SetOccupied(true);

        newEntity.Setup(opposingTeam, node.worldPosition);
        newEntity.WhiteParticlesPlay();
    }
Ejemplo n.º 7
0
    public void AltSetup(EntitiesDatabaseSO.EntityData myData, DeckManager deckref)
    {
        icon.sprite = myData.icon;
        name.text   = myData.name;
        cost.text   = myData.cost.ToString();
        damage.text = myData.damage.ToString();
        health.text = myData.health.ToString();
        //movement.text = myData.movement.ToString();

        if (myData.name.Equals("Tiger"))
        {
            Sprite nimble = Resources.Load <Sprite>("nimble");
            Sprite runner = Resources.Load <Sprite>("runner");
            abilityicon.GetComponent <Image>().sprite  = nimble;
            abilityicon2.GetComponent <Image>().sprite = runner;
        }
        else if (myData.name.Equals("Peasant"))
        {
            Sprite builder = Resources.Load <Sprite>("builder");
            abilityicon.GetComponent <Image>().sprite = builder;
            abilityicon2.enabled = false;
        }
        else if (myData.name.Equals("Avenger"))
        {
            Sprite builder = Resources.Load <Sprite>("builder");
            abilityicon.GetComponent <Image>().sprite = builder;
            abilityicon2.enabled = false;
        }
        else if (myData.movement == 2)
        {
            Sprite runner = Resources.Load <Sprite>("runner");
            abilityicon.GetComponent <Image>().sprite = runner;
            abilityicon2.enabled = false;
        }
        else
        {
            abilityicon.enabled  = false;
            abilityicon2.enabled = false;
        }

        this.myData         = myData;
        this.shopRef        = null;
        this.deckmanagerRef = deckref;
    }
Ejemplo n.º 8
0
    public void AddCard(UICard card, EntitiesDatabaseSO.EntityData myData)
    {
        if (!myData.isBuilding)
        {
            if (index < 5)
            {
                unitsCursors[index].SetActive(false);
                unitsDb.allEntities[index] = myData;
                //SAVE HERE
                unitsNames.Add(myData.name);
                unitsCards[index].gameObject.SetActive(true);
                unitsCards[index].Setup(unitsDb.allEntities[index]);

                index++;
                if (index != 5)
                {
                    unitsCursors[index].SetActive(true);
                }
            }
        }
        else if (myData.isBuilding)
        {
            Debug.Log("Building clicked");
            if (buildingsIndex < 3)
            {
                buildingsCursors[buildingsIndex].SetActive(false);
                buildingsDb.allEntities[buildingsIndex] = myData;
                //SAVE HERE
                buildingsNames.Add(myData.name);
                buildingsCards[buildingsIndex].gameObject.SetActive(true);
                buildingsCards[buildingsIndex].Setup(buildingsDb.allEntities[buildingsIndex]);

                buildingsIndex++;
                if (buildingsIndex != 3)
                {
                    buildingsCursors[buildingsIndex].SetActive(true);
                }
            }
        }
    }
Ejemplo n.º 9
0
 public void DeckSetup(EntitiesDatabaseSO.EntityData myData, DeckManager deckref)
 {
 }
Ejemplo n.º 10
0
    public void OnEntityBought(EntitiesDatabaseSO.EntityData entityData)
    {
        Transform parent = team1Parent;

        if (myTeam == Team.Team1)
        {
            parent = team1Parent;
        }
        else if (myTeam == Team.Team2)
        {
            parent = team2Parent;
        }

        BaseEntity newEntity = Instantiate(entityData.prefab, parent);

        newEntity.gameObject.name = entityData.name;
        newEntity.movement        = entityData.movement;
        newEntity.baseHealth      = entityData.health;
        newEntity.baseDamage      = entityData.damage;
        newEntity.isBuilding      = entityData.isBuilding;
        newEntity.cost            = entityData.cost;

        if (myTeam == Team.Team1)
        {
            team1Entities.Add(newEntity);
        }
        else if (myTeam == Team.Team2)
        {
            team2Entities.Add(newEntity);
        }



        newEntity.Setup(myTeam, /*GridManager.Instance.GetFreeNode(Team.Team1)*/ spawnTransform.transform.position);

        switch (newEntity.gameObject.name)
        {
        case "Peasant":
            SoundFxManager.Instance.PlayBuilder();
            break;

        case "Avenger":
            SoundFxManager.Instance.PlayAvenger();
            break;

        case "Evangelist":
            SoundFxManager.Instance.PlayEvangelist();
            break;

        case "Tiger":
            SoundFxManager.Instance.PlayTiger();
            break;

        case "Jaguar":
            SoundFxManager.Instance.PlayJaguar();
            break;

        default:
            SoundFxManager.Instance.PlayBuilding();
            break;
        }

        spawnFx.Spawn();
        TurnManager.Instance.SetGameState(GameState.Placing);
    }