Ejemplo n.º 1
0
        private List <Event> FilterEvents(EventsRequest request, List <Event> events)
        {
            try
            {
                if (!string.IsNullOrEmpty(request.EventType))
                {
                    EventType type = db.EventTypes.Where(x => x.Name == request.EventType).FirstOrDefault();
                    events = events.Where(x => x.EventTypeId == type.Id).ToList();
                }

                if (!string.IsNullOrEmpty(request.StationName))
                {
                    SolarStation station = db.SolarStations.Where(x => x.Name == request.StationName).FirstOrDefault();
                    events = events.Where(x => x.StationId == station.Id).ToList();
                }
                else if (!string.IsNullOrEmpty(request.InvertorName))
                {
                    Invertor invertor = db.Invertors.Where(x => x.Name == request.InvertorName).FirstOrDefault();
                    events = events.Where(x => x.StationId == invertor.Id).ToList();
                }
                else if (!string.IsNullOrEmpty(request.ErrorMessage))
                {
                    ErrorType type = db.ErrorTypes.Where(x => x.Name == request.ErrorMessage).FirstOrDefault();
                    events = events.Where(x => x.ErrorTypeId == type.Id).ToList();
                }
                return(events);
            }
            catch (NullReferenceException) { return(new List <Event>()); }
        }
Ejemplo n.º 2
0
    private void PostProcessInvertors()
    {
        List <string> conditions = new List <string>()
        {
            "RED",
            "BLUE"
        };

        if (CheckHaveEveryTag(conditions) && !activeTags.Contains("MAGENTA"))
        {
            Invertor invertor = new Invertor();
            invertor.Apply("MAGENTA", invertables, true, conditions);
            postProcessRecursCount += 1;
        }

        postProcessRecursCount -= 1;

        List <Invertor> invertorsToClear = new List <Invertor>();

        foreach (var invertor in activeTagInvertors)
        {
            if (invertor.AddedByPostprocessor)
            {
                if (!CheckHaveEveryTag(invertor.conditionsToStay))
                {
                    invertorsToClear.Add(invertor);
                }
            }
        }

        foreach (var invertor in invertorsToClear)
        {
            invertor.Clear();
        }
    }
Ejemplo n.º 3
0
    private void Start()
    {
        target       = ( VariableGameObject )ScriptableObject.CreateInstance("VariableGameObject");
        target.Value = GameObject.FindGameObjectWithTag("Player");

        // Follow Player
        Node_IsEnemyActive node_IsEnemyActive         = new Node_IsEnemyActive(50, enemyLayermask, transform);
        Invertor           node_IsEnemyActiveInvertor = new Invertor(node_IsEnemyActive);
        Node_Chase         node_Chase = new Node_Chase(2, 100, target, agent, false);

        Sequence sequence_FollowPlayer = new Sequence(new List <BTBaseNode> {
            node_IsEnemyActiveInvertor, node_Chase
        }, "Ninja Sequence: Follow Player");

        // Throw smoke at Guard
        Node_MoveToTransform node_MoveToTransform = new Node_MoveToTransform(GameObject.FindGameObjectWithTag("Cover").transform, agent, 1f);
        Node_ThrowSmoke      node_ThrowSmoke      = new Node_ThrowSmoke(enemyLayermask, 5f, transform, 10f);

        Sequence sequence_ThrowSmoke = new Sequence(new List <BTBaseNode> {
            node_IsEnemyActive, node_MoveToTransform, node_ThrowSmoke
        }, "Throw Smoke");


        tree = new Selector(new List <BTBaseNode> {
            sequence_ThrowSmoke, sequence_FollowPlayer
        });

        if (Application.isEditor)
        {
            gameObject.AddComponent <ShowNodeTreeStatus>().AddConstructor(transform, tree);
        }
    }
Ejemplo n.º 4
0
    private void Update()
    {
        justGrabbed = false;
        invertSymbol.SetActive(false);
        grabTip.SetActive(false);
        releaseTip.SetActive(false);

        RaycastHit hitInfo;

        if (Physics.Raycast(new Ray(transform.position, transform.forward), out hitInfo, 10000, layer))
        {
            invertable = hitInfo.transform.gameObject.GetComponent <Invertable>();
            grabable   = hitInfo.transform.gameObject.GetComponent <Grabable>();
            if (invertable != null)
            {
                if (!playerInput.CoursorFree)
                {
                    invertSymbol.SetActive(true);
                }
                if (Input.GetKeyDown(KeyCode.Mouse0) && !playerInput.CoursorFree)
                {
                    InvertorSlot slot = InvertionManager.Instance.GetFreeInvertorSlot();
                    if (slot != null)
                    {
                        Invertor invertor = new Invertor();
                        slot.TakeSlot(invertor, invertor.Apply(invertable));
                    }
                }
            }

            if (grabable != null && currentGrabable == null)
            {
                grabTip.SetActive(true);
                if (Input.GetKeyDown(KeyCode.F) && !playerInput.CoursorFree)
                {
                    grabable.Grab(grabTransform, 2);
                    currentGrabable = grabable;
                    justGrabbed     = true;
                }
            }
        }

        if (currentGrabable != null)
        {
            releaseTip.SetActive(true);
        }


        if (!justGrabbed && Input.GetKeyDown(KeyCode.F) && currentGrabable != null)
        {
            currentGrabable.Release();
            currentGrabable = null;
        }

        if (currentGrabable != null && currentGrabable.Target != grabTransform)
        {
            currentGrabable = null;
        }
    }
Ejemplo n.º 5
0
        public void InvertorNotConnectToPower()
        {
            IndicatorLight light    = new IndicatorLight();
            Invertor       invertor = new Invertor();

            invertor.Output.ConnectTo(light.Input);

            Assert.IsTrue(light.Lighting);
        }
Ejemplo n.º 6
0
    public void AddTagInvertor(string tag)
    {
        InvertorSlot slot = GetFreeInvertorSlot();

        if (slot != null)
        {
            Invertor invertor = new Invertor();
            slot.TakeSlot(invertor, invertor.Apply(tag, invertables));
        }
    }
Ejemplo n.º 7
0
        public NANDGate()
        {
            _invertor1 = new Invertor();
            _invertor2 = new Invertor();
            _nexus     = new TShapedNexus(_invertor1.Output, _invertor2.Output);

            Input1 = _invertor1.Input;
            Input2 = _invertor2.Input;
            Output = _nexus.GetEndpointAt(2);
        }
Ejemplo n.º 8
0
        public NORGate()
        {
            _orGate   = new ORGate();
            _invertor = new Invertor();

            _orGate.Output.ConnectTo(_invertor.Input);

            Input1 = _orGate.Input1;
            Input2 = _orGate.Input2;
            Output = _invertor.Output;
        }
Ejemplo n.º 9
0
 public override Task <Invertor> GetInvertor(InvertorRequest request, ServerCallContext context)
 {
     try
     {
         Invertor invertor = db.Invertors.Where(x => x.Id == request.InvertorId).FirstOrDefault();
         return(Task.FromResult(invertor));
     }
     catch (NullReferenceException)
     {
         return(Task.FromResult(new Invertor()));
     }
 }
Ejemplo n.º 10
0
    private void Start()
    {
        target          = ( VariableGameObject )ScriptableObject.CreateInstance("VariableGameObject");
        weaponAvailable = ( VariableBool )ScriptableObject.CreateInstance("VariableBool");

        weaponAvailable.Value = false;

        // Patrol Behaviour
        Node_Patrol node_Patrol = new Node_Patrol(waypointsManager, agent);

        Node_TargetVisible node_TargetVisible         = new Node_TargetVisible(agent.transform, target, fov);
        Invertor           node_TargetVisibleInvertor = new Invertor(node_TargetVisible);

        Node_TargetAvailable node_TargetAvailable         = new Node_TargetAvailable(target, active);
        Invertor             node_TargetAvailableInvertor = new Invertor(node_TargetAvailable);

        Sequence sequence_Patrol = new Sequence(new List <BTBaseNode> {
            node_TargetAvailableInvertor, node_Patrol, node_TargetVisibleInvertor
        }, "Guard Sequence: Patrol");

        // Chase & Attack Behaviour
        Node_Bool            node_WeaponAvailable = new Node_Bool(weaponAvailable);
        Node_MoveToTransform node_MoveToTransform = new Node_MoveToTransform(GameObject.FindGameObjectWithTag("Weapon").transform, agent, 2f);             // Again... Not optimal, but it works!
        Node_AcquireWeapon   node_AcquireWeapon   = new Node_AcquireWeapon(GameObject.FindGameObjectWithTag("Weapon").transform, agent, 2f, weaponAvailable);
        Node_Chase           node_Chase           = new Node_Chase(1, 15f, target, agent, true);
        Node_Attack          node_Attack          = new Node_Attack(attackRange.Value, agent, target);

        Sequence sequence_AcquireWeapon = new Sequence(new List <BTBaseNode> {
            node_MoveToTransform, node_AcquireWeapon
        }, "Guard Sequence: Acquire Weapon");
        Selector selector_HasWeapon = new Selector(new List <BTBaseNode> {
            node_WeaponAvailable, sequence_AcquireWeapon
        });
        Sequence sequence_Chase = new Sequence(new List <BTBaseNode> {
            node_TargetAvailable, selector_HasWeapon, node_Chase, node_Attack
        }, "Guard Sequence: Chasing");


        tree = new Selector(new List <BTBaseNode> {
            sequence_Patrol, sequence_Chase
        });

        if (Application.isEditor)
        {
            gameObject.AddComponent <ShowNodeTreeStatus>().AddConstructor(transform, tree);
        }
    }
Ejemplo n.º 11
0
    private void Start()
    {
        target          = (VariableTransform)ScriptableObject.CreateInstance("VariableTransform");
        hasWeapon       = (VariableBool)ScriptableObject.CreateInstance("VariableBool");
        hasWeapon.Value = false;

        //Create your Behaviour Tree here!
        #region patrolling
        // Create target that can be changed by other nodes
        NodePatrol    nodePatrol            = new NodePatrol(0.5f, patrolPoints, agent);
        NodeSeeTarget nodeSeeTarget         = new NodeSeeTarget(GetComponent <FieldOfView>(), agent, transform, target);
        Invertor      invertorSeeTarget     = new Invertor(nodeSeeTarget);
        NodeHasTarget nodeHasTarget         = new NodeHasTarget(target);
        Invertor      invertorNodeHasTarget = new Invertor(nodeHasTarget);
        // Patrol group
        Sequence sequencePatrolling = new Sequence(invertorNodeHasTarget, nodePatrol, invertorSeeTarget);
        #endregion

        #region chasing
        NodeCheckBool     nodeHasWeapon     = new NodeCheckBool(hasWeapon);
        NodeGoToTransform nodeGoToTransform = new NodeGoToTransform(1f, GameObject.FindWithTag("Weapon").transform, agent);
        NodeGetWeapon     nodeGetWeapon     = new NodeGetWeapon(1f, GameObject.FindWithTag("Weapon").transform, agent, hasWeapon);
        NodeChase         nodeChase         = new NodeChase(1f, 5, target, agent, 5f, true);
        NodeAttack        nodeAttack        = new NodeAttack(1f, agent, target);

        Sequence sequenceC1 = new Sequence(nodeGoToTransform, nodeGetWeapon);
        Selector selectorC1 = new Selector(new List <Node>()
        {
            nodeHasWeapon, sequenceC1
        });                                                                                 // param

        Sequence sequenceChasing = new Sequence(nodeHasTarget, selectorC1, nodeChase, nodeAttack);

        #endregion


        tree = new Selector(new List <Node> {
            sequenceChasing, sequencePatrolling
        });

        // Show NodeState in editor
        if (Application.isEditor)
        {
            gameObject.AddComponent <ShowNodeTreeStatus>().AddConstructor(transform, tree);
        }
    }
Ejemplo n.º 12
0
        public void DefaultInvertor()
        {
            PowerSupplier  power    = new PowerSupplier();
            IndicatorLight light    = new IndicatorLight();
            Invertor       invertor = new Invertor();

            invertor.Input.ConnectTo(power.Output);
            invertor.Output.ConnectTo(light.Input);

            power.On();
            Assert.IsFalse(light.Lighting);
            power.Off();
            Assert.IsTrue(light.Lighting);
            power.Toggle();
            Assert.IsFalse(light.Lighting);
            power.Toggle();
            Assert.IsTrue(light.Lighting);
        }
        public DTypeFlipFlopLevelTriggered()
        {
            _RSflipFlop = new RSFlipFlop();
            _andGate1   = new ANDGate();
            _andGate2   = new ANDGate();
            _invertor   = new Invertor();
            _nexus1     = new TShapedNexus(_andGate1.Input1, _andGate2.Input1);
            _nexus2     = new TShapedNexus(_invertor.Input, _andGate2.Input2);

            _invertor.Output.ConnectTo(_andGate1.Input2);
            _andGate1.Output.ConnectTo(_RSflipFlop.Reset);
            _andGate2.Output.ConnectTo(_RSflipFlop.Set);

            Data  = _nexus2.GetEndpointAt(2);
            Clock = _nexus1.GetEndpointAt(2);
            Q     = _RSflipFlop.Q;
            QBar  = _RSflipFlop.QBar;
        }
Ejemplo n.º 14
0
    public void RegisterInvertor(string tag, Invertor invertor)
    {
        activeTagInvertors.Add(invertor);
        activeTags.Add(tag);

        if (activeTags.Contains("NOT TEAPOT") && activeTags.Contains("TEAPOT"))
        {
            GameManager.Instance.LoadLevel("Nothingness");
        }

        if (postProcessRecursCount < 3)
        {
            PostProcessInvertors();
        }
        else
        {
            Debug.Log("Recursion too deep in tag post process!");
        }
    }
Ejemplo n.º 15
0
 public void UnregisterInvertor(string tag, Invertor invertor)
 {
     if (activeTagInvertors.Contains(invertor))
     {
         if (activeTags.Contains(tag))
         {
             activeTags.Remove(tag);
         }
         activeTagInvertors.Remove(invertor);
         if (postProcessRecursCount < 3)
         {
             PostProcessInvertors();
         }
         else
         {
             Debug.Log("Recursion too deep in tag post process!");
         }
     }
 }
Ejemplo n.º 16
0
        public Decoder2To4()
        {
            _invertor1 = new Invertor();
            _invertor2 = new Invertor();
            _andGate00 = new ANDGate();
            _andGate01 = new ANDGate();
            _andGate10 = new ANDGate();
            _andGate11 = new ANDGate();

            _crossNexus1  = new CrossNexus(null, _andGate10.Input1, _invertor1.Input, _andGate11.Input1);
            _crossNexus2  = new CrossNexus(null, _andGate01.Input2, _invertor2.Input, _andGate11.Input2);
            _tshapeNexus1 = new TShapedNexus(_invertor1.Output, _andGate00.Input1, _andGate01.Input1);
            _tshapeNexus2 = new TShapedNexus(_invertor2.Output, _andGate00.Input2, _andGate10.Input2);

            Input1   = _crossNexus1.GetEndpointAt(0);
            Input2   = _crossNexus2.GetEndpointAt(0);
            Output00 = _andGate00.Output;
            Output01 = _andGate01.Output;
            Output10 = _andGate10.Output;
            Output11 = _andGate11.Output;
        }
Ejemplo n.º 17
0
 public void TakeSlot(Invertor newInvertor, string name)
 {
     text.text = name;
     invertor  = newInvertor;
     isFree    = false;
 }