Exemplo n.º 1
0
    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));
    }
Exemplo n.º 2
0
    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());
    }
Exemplo n.º 3
0
        public void Start()
        {
            if (!this.IsValidObject())
            {
                return;
            }

            PubSub.GetEvent <DecreaseHealth>()
            .Subscribe(this.DecreaseHealth);
        }
Exemplo n.º 4
0
    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);
    }
Exemplo n.º 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);
        }
    }
Exemplo n.º 6
0
    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"));
            }
        }
Exemplo n.º 8
0
    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);
    }
Exemplo n.º 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));
    }
Exemplo n.º 10
0
 private void Awake()
 {
     PubSub.GetEvent <PlayerHit>().Subscribe(e => this.PlayAudio(e));
 }
Exemplo n.º 11
0
 void Awake()
 {
     PubSub.GetEvent <CurrentPlayerHealth>().Where(e => e.PlayerID == playerID).Subscribe(this.UpdateHealthBar);
 }