public override void Init(UnitControl _unitControl)
    {
        base.Init(_unitControl);

        Transform shieldAttach = transform.Find(
            "Combot:LeftUpperArm_Skel/" +
            "Combot:LeftLowerArm_Skel/" +
            "Combot:Shield_Attach"
            );

        if (!shieldAttach)
        {
            Debug.Log("No shield attach");
        }

        GameObject shieldObj = Instantiate(shield, shieldAttach, false) as GameObject;

        Debug.Log(shieldObj.name + " is created");
        shieldAnimator = shieldObj.GetComponent <Animator>();
        shieldAnimator.runtimeAnimatorController = animController;

        EventRelay eventRelay = EventRelay.AddRelay(unitControl.gameObject);

        UnityEvent openCallBack = new UnityEvent();

        openCallBack.AddListener(OpenShield);
        eventRelay.AddEvent("OpenShield", openCallBack);

        UnityEvent closeCallBack = new UnityEvent();

        closeCallBack.AddListener(CloseShield);
        eventRelay.AddEvent("CloseShield", closeCallBack);
    }
        /*============================================================================*/
        /* Constructor                                                                */
        /*============================================================================*/

        public ModuleConnectionConfigurator(
            IEventDispatcher localDispatcher,
            IEventDispatcher channelDispatcher)
        {
            _localToChannelRelay = new EventRelay(localDispatcher, channelDispatcher).Start();
            _channelToLocalRelay = new EventRelay(channelDispatcher, localDispatcher).Start();
        }
 public void Destroy()
 {
     _localToChannelRelay.Stop();
     _localToChannelRelay = null;
     _channelToLocalRelay.Stop();
     _channelToLocalRelay = null;
 }
Exemple #4
0
    void OnCollisionEnter(Collision col)
    {
        collisionCount++;
        if (collisionCount == 17)
        {
            collisionCount     = 0;
            transform.position = originalPosition;
            rb.velocity        = Vector2.zero;
            ballSilhouetteParent.gameObject.SetActive(true);
            ballShot = false;
        }
        if (col.gameObject.tag == "Enemy")
        {
            Instantiate(Resources.Load("Prefabs/D"), col.transform.position, Quaternion.identity);
            Destroy(col.gameObject);
            Count++;

            EventRelay.RaiseEvent();

            if (Count == 4)
            {
                StartCoroutine(Restart());
            }
        }
    }
Exemple #5
0
    // IEnumerator footStepSound()
    // {
    //     while (!footStep.isPlaying)
    //     {
    //         footStep.Play();
    //         EventRelay.Notify(transform.position, 1);
    //     }
    //     yield return 0;
    // }

    private void PlayFootStepSound()
    {
        if (!footStep.isPlaying)
        {
            footStep.Play();
            EventRelay.Notify(transform.position, 1);
        }
    }
 // Update is called once per frame
 void Update()
 {
     counter += Time.deltaTime;
     if (counter > delay)
     {
         Debug.Log("broadcast sound");
         counter = 0;
         EventRelay.Notify(transform.position, 1);
     }
 }
Exemple #7
0
                public RelayStream(EventRelay parent, SafeType <TEvent> eventType)
                {
                    this.parent_ = parent;
                    this.convertSourceToThisEmit_ = this.parent_.CompileEmit <TEvent>();
                    this.eventType_ = eventType;

                    foreach (var source in this.parent_.relaySources_)
                    {
                        this.AddSource(source);
                    }
                }
 void Update()
 {
     if (hasFinished)
     {
         string value = EventRelay.RelayEvent(EventRelay.EventMessageType.Finish, this);
         Debug.Log("Finished Event was seen by: " + value);
         hasFinished = false;
     }
     if (hasLost)
     {
         string value = EventRelay.RelayEvent(EventRelay.EventMessageType.TipOver, this);
         Debug.Log("TipOver Event was seen by: " + value);
         hasLost = false;
     }
 }
Exemple #9
0
    void Update()
    {
        if (resetClicked)
        {
            string value = EventRelay.RelayEvent(EventRelay.EventMessageType.Reset, this);
            Debug.Log("Reset Event was seen by: " + value);
            resetClicked = false;
        }

        if (swapClicked)
        {
            string value = EventRelay.RelayEvent(EventRelay.EventMessageType.SwapControls, this);
            Debug.Log("SwapControls Event was seen by: " + value);
            swapClicked = false;
        }
    }
Exemple #10
0
    public void SetOpen(bool isOpen, PlayerControl opener)
    {
        this.isOpen = isOpen;
        if (isOpen)
        {
            openSound.Play();
            EventRelay.Notify(transform.position, 3);
            if (!Vacant())
            {
                //Debug.Log("Something");
                if (insideThing.GetComponent <Compass>() != null)
                {
                    //Debug.Log("Compass Found");
                    if (!opener.compassCollected)
                    {
                        opener.compassCollected = true;
                        Destroy(insideThing);
                        //Debug.Log("Compass Lost");
                    }
                    else
                    {
                        // Alert

                        insideThing.GetComponentInChildren <SpriteRenderer>().enabled = true;
                    }
                }
                if (insideThing.GetComponent <HourGlass>() != null)
                {
                }
                if (insideThing.GetComponent <PlayerControl>() != null)
                {
                }
            }
        }
        else
        {
            closeSound.Play();
            if (!Vacant())
            {
                if (insideThing.GetComponent <Compass>() != null)
                {
                    insideThing.GetComponentInChildren <SpriteRenderer>().enabled = false;
                }
            }
        }
    }
Exemple #11
0
    void StartNextTurn(PlayersMove?previousMove)
    {
        // Update current player index, if it's not the first turn in game
        if (previousMove != null)
        {
            this.currentPlayerIdx = (this.currentPlayerIdx + 1) % this.players.Length;
        }

#if DEBUG
        Debug.LogFormat("<color=blue>Starting player {0} move</color>", this.currentPlayerIdx);
#endif

        // Start player's move
        this.currentPlayer.OnMoveCompleted += this.dOnMoveCompleted;
        EventRelay.FireOnTurnStarted(this.currentPlayer);
        this.currentPlayer.StartMove(previousMove);
    }
 void UserInput(bool msg)
 {
     if (msg == false)
     {
         var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit, 100))
         {
             if (hit.collider.tag == "player1bool")
             {
                 if (Input.GetMouseButtonDown(0))
                 {
                     startPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                     EventRelay.RaiseEvent(EVENT_TYPE.BEGAN, startPos);
                 }
                 if (Input.GetMouseButton(0))
                 {
                     currentPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                     directionVector = startPos - currentPosition;
                     EventRelay.RaiseEvent(EVENT_TYPE.MOVED, directionVector);
                 }
                 if (Input.GetMouseButtonUp(0))
                 {
                     FinaldirectionVector = startPos - currentPosition;
                     EventRelay.RaiseEvent(EVENT_TYPE.ENDED, FinaldirectionVector);
                 }
             }
             else
             {
                 if (Input.GetMouseButtonDown(0))
                 {
                     LeftButton(true);
                     RightButton(true);
                 }
             }
         }
     }
 }
Exemple #13
0
 void Idle_Enter()
 {
     string value = EventRelay.RelayEvent(EventRelay.EventMessageType.CStateEnter, this);
     Debug.Log("Enter Event was seen by: " + value);
 }
Exemple #14
0
    public static EventRelay AddRelay(GameObject target)
    {
        EventRelay relay = target.AddComponent <EventRelay>();

        return(relay);
    }
Exemple #15
0
 void Idle_Exit()
 {
     string value = EventRelay.RelayEvent(EventRelay.EventMessageType.CStateExit, this);
     Debug.LogWarning("Exit Event was seen by: " + value);
 }   
Exemple #16
0
 void OnDestroy()
 {
     EventRelay.ResetEvents();
 }
Exemple #17
0
 public void DoorFlip()
 {
     animator.SetTrigger("PassDoor");
     EventRelay.Notify(transform.position, 2);
 }