Beispiel #1
0
    // Gets references to necessary game components
    public override void init_agent(Pos position, GameAgentStats stats, string name = null)
    {
        map_manager = GameObject.FindGameObjectWithTag("GameController").GetComponent <MapManager>();
        grid_pos    = position;

        this.stats = stats;
        UpdateViewableEditorPlayerStats();
        max_move_budget = 15;
        move_budget     = max_move_budget;
        speed           = 10;
        this.nickname   = name;

        animator     = GetComponent <CharacterAnimator>();
        classDefiner = GetComponent <CharacterClassDefiner>();
        animator.init();
        classDefiner.init(stats.characterRace, stats.characterClassOption, stats.playerCharacterClass.weapon);

        selectableTiles = new List <Pos>();

        currentState = GameAgentState.Alive;
        animating    = false;

        source = GetComponent <AudioSource>();
        inventory.AddItem(new HealthPot(5));
        inventory.AddItem(new ManaPot(5));

        // AI init
        team = 0;
        AI   = null;                            // players don't have AI
        TurnManager.instance.addToRoster(this); //add player to player list
    }
    // instantiates an agent into the map
    public GameObject instantiate(GameObject prefab, Pos pos, GameAgentStats stats = null, string name = null)
    {
        if (!IsWalkable(pos))
        {
            return(null);
        }

        GameObject clone = Instantiate(prefab, grid_to_world(pos), Quaternion.identity);
        GameAgent  agent = clone.GetComponent <GameAgent>();

        //string[] names = new string[] { "Keawa", "Benjamin", "Diana", "Jerry", "Joe" };

        if (stats == null)
        {
            agent.init_agent(pos, new GameAgentStats(CharacterRaceOptions.Human, CharacterClassOptions.Knight, 1, CharacterClassOptions.Sword), name);
        }
        else
        {
            agent.init_agent(pos, stats, name);
        }

        nav_map.removeTraversableTile(pos);
        map[pos.x, pos.y].resident = agent;
        map[pos.x, pos.y].occupied = true;
        return(clone);
    }
    public static void UpdatePlayerStatsMenu(int position, string name, GameAgentStats stats, bool deactivatePlayerSpot = false)
    {
        if (!deactivatePlayerSpot)
        {
            if (position < playerStats.Length)
            {
                if (!playerStats[position].activeSelf)
                {
                    playerStats[position].SetActive(true);
                }

                string hpString = stats.currentHealth.ToString() + "/" + stats.maxHealth.ToString();
                string mpString = stats.currentMagicPoints.ToString() + "/" + stats.maxMagicPoints.ToString();

                playerStats[position].GetComponentInChildren <Text>().text = name;
                FindObjectwithTag("Level", playerStats[position]).transform.GetChild(0).gameObject.GetComponentInChildren <Text>().text = stats.level.ToString();
                FindObjectwithTag("HP", playerStats[position]).transform.GetChild(0).gameObject.GetComponentInChildren <Text>().text    = hpString;
                FindObjectwithTag("MP", playerStats[position]).transform.GetChild(0).gameObject.GetComponentInChildren <Text>().text    = mpString;
            }
        }
        else
        {
            playerStats[position].SetActive(false);
        }
    }
    // Creates a list of enemy stats that will be used for placing in spawn zones
    void CreateEnemyStatsInGroup()
    {
        foreach (EnemyGroupDescription enemy in typesOfEnemies)
        {
            for (int i = 0; i < enemy.quantityOfEnemyInGroup; i++)
            {
                GameAgentStats stats = new GameAgentStats(enemy.stats.characterRace, enemy.stats.characterClassOption, enemy.stats.level, CharacterClassOptions.RandomClassWeapon);
                enemies.Add(stats);
            }
        }

        count = enemies.Count;
    }
    public override void init_agent(Pos position, GameAgentStats stats, string name = null)
    {
        map_manager = GameObject.FindGameObjectWithTag("GameController").GetComponent <MapManager>();
        grid_pos    = position;

        animator = GetComponent <CharacterAnimator>();

        this.stats    = stats;
        _attack       = stats.attack;
        maxHealth     = stats.maxHealth;
        currentHealth = maxHealth;
        range         = stats.range;
        _speed        = stats.speed;
        if (name == null)
        {
            this.nickname = CharacterRaceOptions.getString(stats.characterRace) + " " + CharacterClassOptions.getWeaponDescriptor(stats.playerCharacterClass.weapon);
        }
        else
        {
            this.nickname = name;
        }

        weapon = stats.playerCharacterClass.weapon;

        speed       = 10;
        move_budget = 10;

        level         = stats.level;
        viewableState = stats.currentState;

        animator     = GetComponent <CharacterAnimator>();
        classDefiner = GetComponent <CharacterClassDefiner>();
        animator.init();
        classDefiner.init(stats.characterRace, stats.characterClassOption, stats.playerCharacterClass.weapon);

        source = GetComponent <AudioSource>();

        // AI init
        team = 1;
        AI   = new AIComponent(this);       // AI component that decides the actions for this enemy to take
        TurnManager.instance.addToRoster(this);
        SetCurrentAction(0);
    }
Beispiel #6
0
    public void SetCharacterClass(string classname)
    {
        int weapon, classID;

        switch (classname)
        {
        case "Warrior":
            classID = CharacterClassOptions.Knight;
            weapon  = CharacterClassOptions.Sword;
            break;

        case "Mage":
            classID = CharacterClassOptions.Mage;
            weapon  = CharacterClassOptions.Staff;
            break;

        case "Hunter":
            classID = CharacterClassOptions.Hunter;
            weapon  = CharacterClassOptions.Bow;
            break;

        case "Healer":
            classID = CharacterClassOptions.Healer;
            weapon  = CharacterClassOptions.Staff;
            break;

        default:
            classID = CharacterClassOptions.Knight;
            weapon  = CharacterClassOptions.Sword;
            break;
        }

        stats         = new GameAgentStats(CharacterRaceOptions.Human, classID, 1, weapon);
        _attack       = stats.attack;
        maxHealth     = stats.maxHealth;
        currentHealth = maxHealth;
        range         = stats.range;
        _speed        = stats.speed;

        classDefiner.init(stats.characterRace, stats.characterClassOption, stats.playerCharacterClass.weapon);
    }
    // Variance is based on a percentage from 0 to 1 (1 = 100%)
    // The stat can be potentially rasied to any percetage, but cannot fall below 50% the original stat
    public EnemyGroupDescription(GameAgentStats stats, int quantityOfEnemyInGroup,
                                 float attackVariance          = 0f, float healthVariance = 0f,
                                 float rangeVariance           = 0f, float speedVariance  = 0f,
                                 bool randomNumberOfEnemies    = false,
                                 int minNumberOfEnemiesInGroup = -1, int maxNumberOfEnemiesInGroup = -1, int levelVariance = 0)
    {
        this.stats                     = stats;
        this.attackVariance            = attackVariance;
        this.healthVariance            = healthVariance;
        this.rangeVariance             = rangeVariance;
        this.speedVariance             = speedVariance;
        this.quantityOfEnemyInGroup    = quantityOfEnemyInGroup;
        this.randomNumberOfEnemies     = randomNumberOfEnemies;
        this.minNumberOfEnemiesInGroup = minNumberOfEnemiesInGroup;
        this.maxNumberOfEnemiesInGroup = maxNumberOfEnemiesInGroup;
        this.levelVariance             = levelVariance;

        MapConfiguration config = GameObject.FindGameObjectWithTag("Map").GetComponent <MapConfiguration>();

        rng = config.GetRNG();

        CalculatePowerLevel();
    }
Beispiel #8
0
 public Knight()
 {
     baseStats = new GameAgentStats(20, 100, 2, 7, true);
     rng       = GameObject.FindGameObjectWithTag("Map").GetComponent <MapConfiguration>().GetRNG();
 }
 public Hunter()
 {
     baseStats = new GameAgentStats(18, 80, 9, 9, true);
     rng       = GameObject.FindGameObjectWithTag("Map").GetComponent <MapConfiguration>().GetRNG();
 }
Beispiel #10
0
 public Healer()
 {
     baseStats = new GameAgentStats(16, 65, 7, 10, true);
     rng       = GameObject.FindGameObjectWithTag("Map").GetComponent <MapConfiguration>().GetRNG();
 }
 public EnemyToSpawn(Pos gridPosition, GameAgentStats stats)
 {
     this.gridPosition = gridPosition;
     this.stats        = stats;
 }
 public Mage()
 {
     baseStats = new GameAgentStats(23, 70, 7, 6, true);
     rng       = GameObject.FindGameObjectWithTag("Map").GetComponent <MapConfiguration>().GetRNG();
 }
 public abstract void init_agent(Pos position, GameAgentStats stats, string name = null);