示例#1
0
    //given an index and the type of summon, summons that entity with the next available name
    public void SummonEntity(int cellindex, string summonname, string playerid)
    {
        Vector3 summonindex = hexGrid.GetCellPos(cellindex);

        summonindex.y = 0.2f;

        //Instantiate the prefab from the resources folder, add to player entity list and set it to the hex tile
        GameObject entity   = (GameObject)Instantiate(Resources.Load(summonname), summonindex, Quaternion.identity);
        Guid       entityID = Guid.NewGuid();

        entity.name = entityID.ToString();
        char playerChar = playerid[0];

        entityStorage.PlayerEntityList(playerChar).Add(entity);
        hexGrid.SetEntityObject(cellindex, entity);

        //sets stats for entity
        entityStats.SetPlayerID(entity, playerid);
        entityStats.SetType(entity, summonname);
        entityStats.SetUniqueID(entity, entityID);
        entityStats.SetCellIndex(entity, cellindex);

        int health = entityStats.GetMaxHealth(summonname);

        entityStats.SetMaxHealth(entity, health);
        entityStats.SetCurrHealth(entity, health);
        int mana = entityStats.GetMaxMana(summonname);

        entityStats.SetMaxMana(entity, mana);
        entityStats.SetCurrMana(entity, mana);
        int dmg = entityStats.GetAttackDmg(summonname);

        entityStats.SetAttackDmg(entity, dmg);
        int attpt = entityStats.GetMaxAttackPoint(summonname);

        entityStats.SetMaxAttackPoint(entity, attpt);
        int movept = entityStats.GetMaxMovementPoint(summonname);

        entityStats.SetMaxMovementPoint(entity, movept);
        int range = entityStats.GetRange(summonname);

        entityStats.SetRange(entity, range);
        int rangedattdmg = entityStats.GetRangedAttackDmg(summonname);

        entityStats.SetRangedAttackDmg(entity, rangedattdmg);
        int armor = entityStats.GetArmor(summonname);

        entityStats.SetArmor(entity, armor);
        int armorpiercing = entityStats.GetArmorPiercing(summonname);

        entityStats.SetArmorPiercing(entity, armorpiercing);
        int rangedarmorpiercing = entityStats.GetRangedArmorPiercing(summonname);

        entityStats.SetRangedArmorPiercing(entity, rangedarmorpiercing);
        int vision = entityStats.GetVision(summonname);

        entityStats.SetVision(entity, vision);

        loadMap.CreateHealthLabel(cellindex, health, entity.name);
    }
示例#2
0
 public void SetAllIdleStatus(bool idleStatus, char playerID)
 {
     foreach (GameObject entity in entityStorage.PlayerEntityList(playerID))
     {
         entityStats.SetIdle(entity, idleStatus);
     }
 }
示例#3
0
    void HandleInput()
    {
        if (editmode == true)
        {
            currindex = select.ChangeTerrain(colors, activeColor);
        }
        else
        {
            currindex = select.GetCurrIndex();
        }

        //TODO lock ability for user to save while attack in progress because battle object is not saved

        //-----Selector--------------
        Debug.Log(currindex);
        //string currEntityName = hexGrid.GetEntityName (currindex);
        GameObject currEntityObj   = hexGrid.GetEntityObject(currindex);
        GameObject currBuildingObj = hexGrid.GetBuildingObject(currindex);
        //string cleanCurrEntity = Regex.Replace(currEntityName.Substring(2), @"[\d-]", string.Empty);
        //string cleanCurrBuilding = Regex.Replace(currBuildingName.Substring(2), @"[\d-]", string.Empty);

        char playerChar = playerManager.currPlayer[0];

        if (entityStorage.PlayerEntityList(playerChar).Contains(currEntityObj))
        {
            selectedindex = currindex;
            //TODO list info for curr entity, display it
            lockbattle = false;
        }
        if (buildingStorage.PlayerBuildingList(playerChar).Contains(currBuildingObj))
        {
            buildingManager.DisplayBuilding(currindex);
            //TODO GUI for buildings
        }
        //ensures attacks only happen once per update
        if (lockbattle == false)
        {
            bool checkAttHappen = battle.Attack(selectedindex, currindex);
            if (checkAttHappen == true)
            {
                lockbattle = true;
            }
        }
    }
示例#4
0
    //valid if have soul cost and entity/corpse cost
    public bool ValidBuilding(string building, int index)
    {
        string faction = buildingStorage.WhichFactionBuilding(building);

        switch (faction)
        {
        case FactionNames.Undead:
            int souls = currency.souls;
            int cost  = buildingStorage.buildingSoulCost(building);

            List <string> corpses = hexGrid.GetCorpses(index);
            GameObject    entity  = hexGrid.GetEntityObject(index);

            //checks if fulfilled cost and removes paid cost from game
            if (souls >= cost)
            {
                if (corpses.Contains(EntityNames.Militia))
                {
                    currency.ChangeSouls(-cost);
                    hexGrid.RemoveCorpse(index, EntityNames.Militia);
                    return(true);
                }
                else if (entityStats.GetType(entity) == EntityNames.Skeleton || entityStats.GetType(entity) == EntityNames.Zombie || entityStats.GetType(entity) == EntityNames.SkeletonArcher)
                {
                    currency.ChangeSouls(-cost);
                    GameObject entityGameObj     = hexGrid.GetEntityObject(index);
                    char       playerFirstLetter = entityStats.GetPlayerID(entity)[0];
                    entityStorage.PlayerEntityList(playerFirstLetter).Remove(entityGameObj);
                    Destroy(entityGameObj);
                    hexGrid.SetEntityObject(index, null);
                    GameObject healthText = GameObject.Find("Health " + entityStats.GetUniqueID(entity).ToString());
                    Destroy(healthText);
                    return(true);
                }
            }
            return(false);

        case "humans":
            return(true);
        }
        return(false);
    }
示例#5
0
    //check each player entity in entitystorage to determine their vision range and remove the fog for that range
    public void EntityCurrPlayerVision()
    {
        if (playerManager.currPlayer != string.Empty)
        {
            char playerChar = playerManager.currPlayer[0];
            //Debug.Log(entityStorage.PlayerEntityList(playerChar)[0].name.Substring(2));
            foreach (GameObject playerEntity in entityStorage.PlayerEntityList(playerChar))
            {
                int    visionDistance = entityStats.GetCurrVision(playerEntity);
                int    index          = entityStats.GetCellIndex(playerEntity);
                string height         = hexGrid.GetTerrain(index);

                Dictionary <int, int> vision = PlayerVisionHelper(index, visionDistance, height);
                foreach (var tile in vision)
                {
                    hexGrid.SetFog(tile.Key, false);
                    Fog fog = fogs[tile.Key];
                    fog.GetComponent <Renderer>().enabled = false;
                }
            }
            foreach (GameObject buildingEntity in buildingStorage.PlayerBuildingList(playerChar))
            {
                int    visionDistance = buildingStats.GetCurrVision(buildingEntity);
                int    index          = buildingStats.GetCellIndex(buildingEntity);
                string height         = hexGrid.GetTerrain(index);

                Dictionary <int, int> vision = PlayerVisionHelper(index, visionDistance, height);
                foreach (var tile in vision)
                {
                    if (tile.Value >= -2)
                    {
                        hexGrid.SetFog(tile.Key, false);
                        Fog fog = fogs[tile.Key];
                        fog.GetComponent <Renderer>().enabled = false;
                    }
                }
            }
        }
    }