public Player() { this.attack = null; this.parry = null; this.lastVelocity = new Vector2(); this.lives = 5; }
//Called when this players attack is parried //attack is this player's attack that was parried //by is the enemy's parry that stoppped this attack private void Parried_(Attack attack, Parry by) { attack.Cut(this); //Call the enemies parry success by.Success(this.nodeEnemy); this.Knockback(by.knockback); }
//Same as Parried_(Attack, Parry) //However instead uses the indexes, to allow for less data to be sent by over RPC //attackindex is the index of of the attack that was parried in this.actions //byindex is the index of of the parry in this.nodeEnemy.actions private void Parried_ByIndex_(int attackindex, int byindex) { Attack attack = this.actions[attackindex] as Attack; Parry by = this.nodeEnemy.actions[byindex] as Parry; this.Parried_(attack, by); }
//public wrapper function for Parried_(..) //Used to ensure that Parried_(..) is only called by the server in multiplayer //Passes straight through to Parried_(..) in singleplayer public void Parried(Attack attack, Parry by) { if (Lobby.role != Lobby.MultiplayerRole.OFFLINE) { if (Lobby.IsHost) //Only issue calls if host { RpcMaybeReliable(nameof(this.Parried_ByIndex_), new object[] { this.actions.IndexOf(attack), this.nodeEnemy.actions.IndexOf(by) }); } } else { this.Parried_(attack, by); } }