public void Init(Player player)
    {
        this.Player = player;
        this.CurrentMovementDirection = this.Player.StartingMovementDirection;

        this.CanJump = true;

        this.IsBlocking = new BehaviorSubject <CurrentPlayerIsBlocking>(new CurrentPlayerIsBlocking(this.Player, false));

        this.Register(this.IsBlocking);

        this.Rigidbody = this.GetComponent <Rigidbody>();

        if (this.Rigidbody != null)
        {
            PubSub.GetEvent <PlayerMove>().Where(e => e.JoystickID == this.Player.Id).Subscribe(this.Move);
            PubSub.GetEvent <PlayerJump>().Where(e => e.JoystickID == this.Player.Id).Subscribe(this.Jump);
        }

        PubSub.GetEvent <CurrentPlayerOpponent>().Where(e => e.Player == this.Player).Subscribe(e => this.CurrentOpponent = e.Opponent);

        this.Subscribe <FightOver>(e => this.EnableCameraBounds(false));
        this.Subscribe <PlayersSpawned>(e => this.EnableCameraBounds(true));

        this.Subscribe <FightOver>(e => this.EnableInput(false));
        this.Subscribe <RoundStarted>(e => this.EnableInput(true));
    }
    private void Awake()
    {
        PubSub.GetEvent <PlayerAttack>().Subscribe(e => this.PlayAudio(e));
        PubSub.GetEvent <PlayerJumpStart>().Subscribe(e => this.PlayJumpStartAudio(e));
        PubSub.GetEvent <PlayerJumpEnd>().Subscribe(e => this.PlayJumpEndAudio(e));

        this.Subscribe <CharacterSelectChange>(e => this.UiLeftRight());
        this.Subscribe <CharacterSelectReadyChange>(e => this.UiSelect());
    }
Exemple #3
0
        public void Start()
        {
            if (!this.IsValidObject())
            {
                return;
            }

            PubSub.GetEvent <DecreaseHealth>()
            .Subscribe(this.DecreaseHealth);
        }
    public void Init(Player player)
    {
        this.Player = player;

        this.CurrentPlayerOpponent = new BehaviorSubject <CurrentPlayerOpponent>(new CurrentPlayerOpponent(this.Player, null));

        this.Register(this.CurrentPlayerOpponent);

        PubSub.GetEvent <PlayerSpawned>().Where(e => e.Player != this.Player).Subscribe(this.RegisterOpponent);
    }
Exemple #5
0
    public void Init(Player player)
    {
        this.PlayerId = player.Id;

        this.Animator = this.GetComponent <Animator>();

        if (this.Animator != null)
        {
            PubSub.GetEvent <PlayerMoved>().Where(e => e.PlayerID == this.PlayerId).Subscribe(this.PlayerMoved);
            PubSub.GetEvent <PlayerAttack>().Where(e => e.JoystickID == this.PlayerId).Subscribe(this.PlayerAttack);
        }
    }
    public void Init(Player player)
    {
        this.Player = player;

        this.gameObject.layer = LayerMask.NameToLayer("Body");

        this.HitImpact   = Resources.Load("Prefabs/HitImpact") as GameObject;
        this.BlockImpact = Resources.Load("Prefabs/BlockImpact") as GameObject;

        PubSub.GetEvent <PlayerAttacking>().Where(e => e.Opponent == this.Player).Subscribe(this.PlayerHit);

        PubSub.GetEvent <CurrentPlayerIsBlocking>().Where(e => e.Player == this.Player).Subscribe(this.CurrentPlayerIsBlocking);
    }
        private void Awake()
        {
            this.Text = this.GetComponent <Text>();

            if (this.Text != null)
            {
                // Subscribes to HealthChange events where the amount is greater than zero and calls SetText() in response.
                PubSub.GetEvent <HealthChange>().Where(e => e.Amount > 0).Subscribe(e => this.SetText("Health increased"));

                // Subscribes to HealthChange events where the amount is less than zero and calls SetText() in response.
                PubSub.GetEvent <HealthChange>().Where(e => e.Amount < 0).Subscribe(e => this.SetText("Health decreased"));
            }
        }
    public void Init(Player player)
    {
        this.Player = player;

        this.CurrentHealth = new BehaviorSubject <CurrentPlayerHealth>(new CurrentPlayerHealth(this.Player.Id, this.Player.MaxHealth));

        this.Register(this.CurrentHealth);

        PubSub.GetEvent <HealthChange>().Where(e => e.playerID == this.Player.Id).Subscribe(e => this.SetHealth(e));

        PubSub.GetEvent <PlayerHit>().Where(e => e.PlayerID == this.Player.Id).Subscribe(e => this.TakeDamage(e));

        this.Subscribe <RoundStarted>(e => this.IsActive     = true);
        this.Subscribe <PlayerKnockedOut>(e => this.IsActive = false);
    }
Exemple #9
0
    public void Init(Player player, AttackType attackType)
    {
        this.Player       = player;
        this.AttackType   = attackType;
        this.MeshCollider = this.gameObject.AddComponent <MeshCollider>();
        this.Rigidbody    = this.gameObject.AddComponent <Rigidbody>();

        this.gameObject.layer = LayerMask.NameToLayer("Limb");

        this.InitMeshCollider();
        this.InitRigidBody();

        PubSub.GetEvent <PlayerAttack>().Where(e => e.JoystickID == this.Player.Id).Subscribe(this.Attack);

        PubSub.GetEvent <CurrentPlayerOpponent>().Where(e => e.Player == this.Player).Subscribe(e => this.CurrentOpponent = e.Opponent);

        this.Subscribe <FightOver>(e => this.EnableInput(false));
        this.Subscribe <RoundStarted>(e => this.EnableInput(true));
    }
 private void Awake()
 {
     PubSub.GetEvent <PlayerHit>().Subscribe(e => this.PlayAudio(e));
 }
Exemple #11
0
 void Awake()
 {
     PubSub.GetEvent <CurrentPlayerHealth>().Where(e => e.PlayerID == playerID).Subscribe(this.UpdateHealthBar);
 }