Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        player = GameObject.Find("Player");
        agent  = GetComponent <NavMeshAgent>();
        power  = GetComponent <PowerConsumer>();

        //default behavior is to do nothing
        if (nextNode == null)
        {
            nextNode = new GameObject();
            nextNode.transform.position = transform.position;
            nextNode.AddComponent <Node>();
        }

        float difficulty = GameObject.Find("Difficulty").GetComponent <Difficulty>().difficulty;

        if (difficulty != 0)
        {
            attackCooldownMax /= difficulty;
            if (agent.speed != 0)
            {
                agent.speed = agent.speed - 2 + difficulty * 2;
            }
        }
    }
Beispiel #2
0
    private void AddPowerConsumer(PowerConsumer consumer)
    {
        PowerConsumerGUI obj = Instantiate(PowerConsumerGUI);

        obj.transform.SetParent(Content.transform, false);

        obj.AddPowerConsumer(consumer);
    }
Beispiel #3
0
    public bool FindPath(NodeInterface start_node, NodeInterface end_node, bool include_off_paths)
    {
        List <NodeInterface> _TouchedNodes = new List <NodeInterface>();

        _TouchedNodes.Add(start_node);
        Queue <NodeInterface> _Nodes = new Queue <NodeInterface>();

        foreach (NodeConnection c in start_node.Connections)
        {
            PowerConsumer power_consumer_comp = c.GetComponent <PowerConsumer>();

            if (!include_off_paths && (!power_consumer_comp || !power_consumer_comp.IsActive))
            {
                continue;
            }

            NodeInterface _OtherNode = c.GetOtherConnection(start_node);

            if (_OtherNode == end_node)
            {
                return(true);
            }
            else
            {
                _Nodes.Enqueue(_OtherNode);
                _TouchedNodes.Add(_OtherNode);
            }
        }

        while (_Nodes.Count > 0)
        {
            NodeInterface _currentNode = _Nodes.Dequeue();

            foreach (NodeConnection c in _currentNode.Connections)
            {
                PowerConsumer power_consumer_comp = c.GetComponent <PowerConsumer>();

                if (!include_off_paths && (!power_consumer_comp || !power_consumer_comp.IsActive))
                {
                    continue;
                }

                NodeInterface _OtherNode = c.GetOtherConnection(_currentNode);

                if (_OtherNode == end_node)
                {
                    return(true);
                }
                else if (!_TouchedNodes.Contains(_OtherNode))
                {
                    _Nodes.Enqueue(_OtherNode);
                    _TouchedNodes.Add(_OtherNode);
                }
            }
        }
        return(false);
    }
    // Start is called before the first frame update
    protected override void Start()
    {
        base.Start();
        PowerConsumer power_consumer = GetComponent <PowerConsumer>();

        if (power_consumer)
        {
            m_Active = power_consumer.IsActive;
        }
    }
Beispiel #5
0
        public static bool Prefix(PowerConsumer __instance, ref bool __result)
        {
            if (__instance.baseComp == null && __instance.powerRelay != null)
            {
                __result = __instance.powerRelay.IsPowered();
                return(false);
            }

            return(true);
        }
Beispiel #6
0
    public void AddPowerConsumer(PowerConsumer consumer)
    {
        PowerConsumer = consumer;

        ID.text = "ID: " + consumer.ID;
    }