Пример #1
0
    public bool HireAgent(AgentConfig agentConfig)
    {
        if (player.UseGold(agentConfig.GetCost()))
        {
            GameObject agent          = Instantiate(agentConfig.GetAgentPrefab(), player.transform.Find("Agents"));
            Agent      agentComponent = agent.GetComponent <Agent>();
            agentComponent.SetPlayer(player);

            agent.transform.position = this.transform.position + RandomDirection();
            agentComponent.SetAgentName("Agent Smith");
            foreach (AbilityConfig ability in agentConfig.GetAbilities())
            {
                agentComponent.AddAbility(ability);
            }
            agentComponent.SetPortrait(agentConfig.GetRandomPortrait());
            player.AddAgent(agent);

            return(true);
        }
        else
        {
            return(false);
        }
    }