Beispiel #1
0
    public CombatController CreateCombatController(Character character, AICharacterData data, Faction faction)
    {
        var aiGO = CreateGameObject(data, faction);

        character.ownerGO = aiGO;
        aiGO.GetComponentInChildren <CharacterMouseInput>().owner = character;

        if (data.positionPreference == AICharacterData.PositionPreference.PrefersFront)
        {
            character.IsInMelee = true;
        }
        else if (data.positionPreference == AICharacterData.PositionPreference.PrefersBack)
        {
            character.IsInMelee = false;
        }
        else
        {
            character.IsInMelee = Random.value > 0.5f;
        }


        DesertContext.QuickBind(character);

        var aiController = CreateCombatController(aiGO);

        HookCharacterIntoController(aiController, character, data);
        SetupHealthVisuals(character, aiGO);
        aiController.Init();

        DesertContext.FinishQuickBind <Character>();

        return(aiController);
    }
    public TravelingStory CreateSpecificStory(Vector2 position, TravelingStoryData data, TravelingStoryAIData aiOverride = null)
    {
        spriteToUse = data.art;

        var travelingStory = DesertContext.StrangeNew <TravelingStoryController>();

        travelingStory.PopupText = "<u>" + data.dataName + "</u>\n" + data.difficulty + " difficulty";
        travelingStory.action    = CreateAction(data);
        if (aiOverride != null)
        {
            travelingStory.ai = aiOverride.Create();
        }
        else
        {
            travelingStory.ai = data.ai.Create();
        }
        travelingStory.stealthRating = data.stealthRating;

        DesertContext.QuickBind <TravelingStoryMediated>(travelingStory);
        var travelingStoryGO = GameObject.Instantiate(PrefabGetter.travelingStoryPrefab, parent);

        DesertContext.FinishQuickBind <TravelingStoryMediated>();

        travelingStoryGO.GetComponent <TravelingStoryVisuals>().Setup(spriteToUse);
        travelingStory.TeleportToPosition(position);
        travelingStory.Setup();

        return(travelingStory);
    }
Beispiel #3
0
    public GameObject Create(Town t)
    {
        DesertContext.QuickBind(t);
        var go = GameObject.Instantiate(prefab) as GameObject;

        DesertContext.FinishQuickBind <Town>();

        return(go);
    }
Beispiel #4
0
    void SetupHealthVisuals(Character enemyCharacter, GameObject enemyGO)
    {
        var dooberHelper = DesertContext.StrangeNew <CombatDamageDooberHelper>();

        dooberHelper.Setup(enemyCharacter.health, enemyGO);

        DesertContext.QuickBind(enemyCharacter.health);
        var healthDisplayGO = GameObject.Instantiate(PrefabGetter.healthDisplayPrefab) as GameObject;

        DesertContext.FinishQuickBind <Health>();

        healthDisplayGO.transform.SetParent(enemyGO.transform, true);
        healthDisplayGO.transform.localPosition = new Vector3(0, 0.5f, 0);
    }
Beispiel #5
0
    public GameObject CreateDisplayForCity(Town t)
    {
        townsAndCities.DiscoverLocation(t);

        DesertContext.QuickBind(t);
        var cityGO = GameObject.Instantiate(PrefabGetter.cityDisplayPrefab);

        cityGO.transform.SetParent(PrefabGetter.baseCanvas, false);
        DesertContext.FinishQuickBind <Town>();

        activeCityGO = cityGO;

        return(cityGO);
    }
Beispiel #6
0
    public CombatController CreatePlayerCombatCharacter()
    {
        var go = CreateGameObject();

        var character = CreateCharacter(go);

        go.GetComponentInChildren <CharacterMouseInput>().owner = character;
        //TODO: This should be a player set value.
        character.IsInMelee = BasePlayerCharacterStats.Instance.positionPreference == AICharacterData.PositionPreference.PrefersFront;

        DesertContext.QuickBind(character);

        var controller = CreateController(go);

        HookCharacterIntoController(controller, character);
        SetupHealthVisuals(character, go);
        controller.Init();

        DesertContext.FinishQuickBind <Character>();

        return(controller);
    }