public int CastServer(PlayerSpellCaster caster, Vector3 position, Vector3 direction) { _timeAvailableToCast = Time.time + Spell.CoolDown; var handler = (SpellHandler)SpellHandler.Instantiate(Spell.Handler); handler.Id = _serverCastId++; handler.Spell = Spell; handler.Caster = caster; _handlers.Add(handler.Id, handler); Debug.Log(string.Format("Server casting spell:{0} id:{1}", Spell.name, handler.Id)); handler.Cast(position, direction); return(handler.Id); }
public void CastClient(int spellHandlerId, PlayerSpellCaster caster, Vector3 position, Vector3 direction) { //_serverCastId = spellHandlerId; _timeAvailableToCast = Time.time + Spell.CoolDown - Network.GetAveragePing(Network.player) / 1000f; var handler = (SpellHandler)SpellHandler.Instantiate(Spell.Handler); handler.Id = spellHandlerId; handler.Spell = Spell; handler.Caster = caster; _handlers.Add(handler.Id, handler); Debug.Log(string.Format("Client casting spell:{0} id:{1}", Spell.name, spellHandlerId)); handler.Cast(position, direction); // process queued events if (_queuedEvents.ContainsKey(spellHandlerId)) { handler.OnSpellEvent(_queuedEvents[spellHandlerId]); _queuedEvents.Remove(spellHandlerId); } }
void Start() { _movement = GetComponent <PlayerMovement>(); _spellCaster = GetComponent <PlayerSpellCaster>(); }