示例#1
0
 public void SetAllMovementPoints(int playerID)
 {
     foreach (GameObject entity in entityStorage.GetPlayerEntityList(playerID))
     {
         entityStats.SetCurrMovementPoint(entity, entityStats.GetCurrMaxMovementPoint(entity));
     }
 }
示例#2
0
 public void LoadEntities()
 {
     for (int i = 0; i < GameMemento.current.entityMementoList.Count; i++)
     {
         summon.SummonEntityMemento(GameMemento.current.entityMementoList[i]);
         //Add Entity To PlayerLists
         entityStorage.GetPlayerEntityList(GameMemento.current.entityMementoList[i].playerID).Add(hexGrid.GetEntityObject(GameMemento.current.entityMementoList[i].cellIndex));
     }
 }
示例#3
0
    void HandleInput()
    {
        if (editmode == true)
        {
            currIndex = select.ChangeTerrain(colors, activeColor);
        }
        else
        {
            currIndex = select.GetCurrIndex();
        }

        if (currIndex == selIndex) //TODO return if hit UI object
        {
            return;
        }

        //-----Selector--------------
        Debug.Log(currIndex);
        GameObject selEntityObj    = hexGrid.GetEntityObject(selIndex);
        GameObject currEntityObj   = hexGrid.GetEntityObject(currIndex);
        GameObject currBuildingObj = hexGrid.GetBuildingObject(currIndex);

        avaliableActions = new List <string>();

        if (entityStorage.GetPlayerEntityList(playerManager.currPlayer).Contains(currEntityObj))
        {
            movement.UnhighlightPossMovement(hexGrid.GetEntityObject(selIndex));
            movement.UnhighlightPossAttack(hexGrid.GetEntityObject(selIndex));
            //display all possible positions
            movement.HighlightPossMovement(currEntityObj, currIndex);
            movement.HighlightPossAttack(currEntityObj, currIndex);
            //TODO list info for curr entity, display it
            avaliableActions = entityStats.GetCurrSpecialActions(currEntityObj);
            lockbattle       = false;
        }
        if (buildingStorage.GetPlayerBuildingList(playerManager.currPlayer).Contains(currBuildingObj))
        {
            buildingManager.DisplayBuilding(currIndex);
            //TODO GUI for buildings
        }
        //ensures attacks only happen once per update
        //TODO add here: lock ability for user to save while attack in progress because battle object is not saved
        if (lockbattle == false && selEntityObj != null)
        {
            battle.PerformAction(selIndex, currIndex, chosenAction);
            lockbattle = true;
        }

        selIndex = currIndex;
    }
示例#4
0
    //valid if have soul cost and entity/corpse cost
    public bool ValidBuilding(string building, int index)
    {
        string faction = buildingStats.WhichFactionBuilding(building);

        switch (faction)
        {
        case FactionNames.Undead:
            int souls = currency.aether;
            int cost  = buildingStats.buildSoulCost(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.ChangeAether(-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.ChangeAether(-cost);
                    GameObject entityGameObj = hexGrid.GetEntityObject(index);
                    entityStorage.GetPlayerEntityList(entityStats.GetPlayerID(entity)).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 != 0)
        {
            foreach (GameObject playerEntity in entityStorage.GetPlayerEntityList(playerManager.currPlayer))
            {
                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.GetPlayerBuildingList(playerManager.currPlayer))
            {
                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;
                    }
                }
            }
        }
    }
示例#6
0
    //given an index and the type of summon, summons that entity with the next available name
    public void SummonEntity(int cellindex, string summonname, int 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();
        entityStorage.GetPlayerEntityList(playerid).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);

        List <string> specialActions = entityStats.GetSpecialActions(summonname);

        entityStats.SetSpecialActions(entity, specialActions);
        List <string> permaEffects = entityStats.GetPermaEffects(summonname);

        entityStats.SetPermaEffects(entity, permaEffects);
        List <KeyValuePair <string, int> > tempEffects = entityStats.GetTempEffects(summonname);

        entityStats.SetTempEffects(entity, tempEffects);

        loadMap.CreateHealthLabel(cellindex, health, entity.name);
    }