Beispiel #1
0
    //-----------------------------------------------------------------------------------------------
    private void GetAllReferencesAsNeeded()
    {
        if (m_strategyPlanner == null)
        {
            m_strategyPlanner = FindObjectOfType <StrategyPlanner>();
            m_strategyPlanner.Awake();
            m_strategyPlanner.Start();
        }

        if (m_aiManager == null)
        {
            m_aiManager = FindObjectOfType <AIManager>();
            m_aiManager.Awake();
        }

        m_buttons = FindObjectsOfType <Button>();

        if (m_influenceGameManager == null)
        {
            m_influenceGameManager = FindObjectOfType <InfluenceGameManager>();
        }

        if (m_influenceSystemRef == null)
        {
            m_influenceSystemRef = InfluenceSystem.GetInstance();
        }

        m_influenceGameManager.ReloadInfluenceMapData();
        m_influenceGameManager.RegisterAllActiveInfluenceObjectsInScene();
        m_influenceGameManager.UpdateInfluenceSystem();
    }
    //-----------------------------------------------------------------------------------------------
    public void Awake()
    {
        GetInfluenceSystemReferencesIfNeeded();

        m_influenceGameManager.Awake();
        m_influenceGameManager.ReloadInfluenceMapData();
        m_influenceGameManager.RegisterAllActiveInfluenceObjectsInScene();
        m_influenceGameManager.UpdateInfluenceSystem();
    }
    //-----------------------------------------------------------------------------------------------
    public override void Run()
    {
        AgentToOperateOn.transform.position = ObjectToMoveTo.transform.position;

        InfluenceGameManager influenceManager = GameObject.FindObjectOfType <InfluenceGameManager>();

        influenceManager.UpdateInfluenceSystem();
    }
Beispiel #4
0
    //-----------------------------------------------------------------------------------------------
    public override void Run()
    {
        OperatorParam influenceMapParamName = FindParamWithName("Influence");

        // Can't exactly move if we don't have a goal
        if (influenceMapParamName == null)
        {
            return;
        }

        string[] mapIdentifiers = influenceMapParamName.Value.Split('_');

        // Determine map type
        InfluenceSystem   influenceSys = InfluenceSystem.GetInstance();
        InfluenceMapPoint mapPoint;

        if (mapIdentifiers[0].Equals("Base", StringComparison.CurrentCultureIgnoreCase))
        {
            WorkingMap queryMap = new WorkingMap();
            queryMap.AddMap(influenceSys.GetInfluenceMapByIDWithTag(mapIdentifiers[1], mapIdentifiers[2]));
            queryMap.Normalize();
            mapPoint = queryMap.GetPointOfHighestInfluence();
        }
        else if (mapIdentifiers[0].Equals("Formula", StringComparison.CurrentCultureIgnoreCase))
        {
            MapFormula formulaToUse = influenceSys.GetMapFormulaByID(mapIdentifiers[1]);
            WorkingMap queryMap     = formulaToUse.ConstructMapFromFormula();
            mapPoint = queryMap.GetPointOfHighestInfluence();
        }
        else
        {
            throw new ArgumentException("Invalid name for influence map in move to operator!");
        }

        InfluenceObjectWorldPoint worldPoint = influenceSys.ConvertMapPosToWorldPos(mapPoint);
        Vector2 newLocation = new Vector2(worldPoint.x, worldPoint.y);

        AgentToOperateOn.transform.position = newLocation;

        InfluenceGameManager influenceManager = GameObject.FindObjectOfType <InfluenceGameManager>();

        influenceManager.UpdateInfluenceSystem();
    }