private void PlayerDied() { PlayerActionEvent evt = CreateEvent <PlayerActionEvent>(); evt.SetDead(); AddEvent(evt); }
private void PlayerIdle() { PlayerActionEvent evt = CreateEvent <PlayerActionEvent>(); evt.SetIdle(); AddEvent(evt); }
public static PlayerActionEvent Map(this PlayerActionEvent toItem, ActionRequest fromItem, Actions actions) { toItem.ActionRefId = actions.FirstOrDefault(e => e.ActionId == fromItem.ActionId).EntityRefId; toItem.OccurredOn = fromItem.OccurredOn; return(toItem); }
protected override void InitEvents() { overlapCheckData = new OverlapCheckData( onEnter: overlap => { // Deal Damage PlayerStats.Inst.DealDamage(flameDashAttackData, overlap.gameObject); }); onDashing = this.NewPlayerActionEvent(() => { // Check Overlap overlapCheckData.OverlapCheckOnce(Physics2D.OverlapBoxAll(GM.PlayerPos, damageSize, 0f, damageLayer)); // Play Particle Effect flameParticle.Play(); }); onDashEnd = this.NewPlayerActionEvent(() => { // Clear Overlap Data overlapCheckData.Clear(); // Stop Particle Effect flameParticle.Stop(); }); }
public void Handler(Event HandledEvent) { if (HandledEvent.GetCode() == Events.Code_PlayerActionEvent) { PlayerActionEvent pae = (PlayerActionEvent)HandledEvent; if (pae.Action == PlayerActionEvent.Actions.Chat) { string[] message = ((string)pae.Data[0]).Split(' ', '.', ',', ':', ';'); string return_message = string.Empty; foreach (var mat in MatsList) { foreach (var mess in message) { if (mat.ToLower() == mess.ToLower()) { return_message += mess.Replace(mess.Substring(1, mess.Length - 1), new string('*', mess.Length - 1)); Flag = true; pae.Cancelled = true; } } } if (Flag) { Server.BroadcastMessage(pae.Player.Name + ": " + return_message); } } } }
public static void RemoveEvent(PlayerActions action, PlayerActionEvent actionEvent) { if (events[action].Contains(actionEvent)) { events[action].Remove(actionEvent); } }
public void Init(IceStaffItem iceStaffItem, OBB_IceStaff_Data data) { this.iceStaffItem = iceStaffItem; this.data = data; iceStaffItem.Sub_DamageTick.SetActive(true); iceStaffItem.Sub_ManaUsageTick.SetActive(true); onKill = this.NewPlayerActionEvent(() => { if (PlayerStats.Inst.CurAttackData.HasValue && PlayerStats.Inst.CurAttackData.Value.damageDealer == gameObject) { var dropTable = PlayerStats.Inst.KilledMob.GetComponent <Mob_DropItem>(); if (dropTable == null) { return; } dropTable.add_drop_table(ItemDB.Inst.GetItemPrefab <FrozenSoul>(), 100f, new RangeInt() { min = 1, max = 1 }); } }); PlayerActionEventManager.AddEvent(PlayerActions.Kill, onKill); }
public AttackAction Attack() { var result = PlayerActionEvent?.Invoke(true); return((AttackAction)result); //throw new NotImplementedException(); }
private void Start() { pAction = this.GetComponent <PlayerActionEvent>(); pAction.OnHit += OnHit; pAction.OnDead += OnDead; isDead = false; }
// Use this for initialization void Start() { camera = GetComponent <Camera>(); if (actionEvent == null) { actionEvent = new PlayerActionEvent(); } }
protected override void InitEvents() { onShoot = this.NewPlayerActionEvent(() => { Bullet bullet = phantomPistolObject.SpawnBullet(); bullet.InitData(bullet.transform.right, projectileData, attackData); }); }
void onPlayerMove(PlayerActionEvent cEvent) { if (cEvent.isCancelled) { return; } if (cEvent.action == PlayerAction.Jump) { jump.play(); } }
public IPlayerAction SelectPlayerAction(bool isAttack = false) { var result = PlayerActionEvent?.Invoke(isAttack); //WaitForPlayerAction.WaitOne(); //Thread.CurrentThread.Suspend(); return(result); //return new NoneAction(); throw new NotImplementedException(); }
protected override void InitEvents() { onDealDamage = this.NewPlayerActionEvent(() => { PlayerStats.Inst.DamageToDeal += MathD.Round(PlayerStats.Inst.DamageToDeal * (effectPercent * 0.01f)); }); onDamaged = this.NewPlayerActionEvent(() => { PlayerStats.Inst.DamageToReceive += MathD.Round(PlayerStats.Inst.DamageToReceive * (effectPercent * 0.01f)); }); }
protected override void InitEvents() { onShieldChanged = this.NewPlayerActionEvent(() => { // Check Shield Health if (PlayerStats.Inst.GetShieldAt(shieldIndex).IsMin) { // Deactivate Item Deactivate(); } }); }
// public bool touchingJumpable (Collider2D trigger, ContactFilter2D filter) { // Collider2D[] colliders = new Collider2D[4]; // smaller array = better performance but more detection mistakes // trigger.OverlapCollider (filter, colliders); // foreach (Collider2D collider in colliders) { // if (!collider) continue; // Solid solid = collider.gameObject.GetComponent<Solid> (); // if (!solid || solid.isJumpable) return true; // } // return false; // } void doJump() { PlayerActionEvent newEvent = new PlayerActionEvent(this, PlayerAction.Jump); newEvent.call(); if (newEvent.isCancelled) { return; } player.velocity = new Vector2(player.velocity.x, 0); player.AddForce(Vector2.up * behaviour.jumpImpuls, ForceMode2D.Impulse); }
void doRightWallJump() { PlayerActionEvent newEvent = new PlayerActionEvent(this, PlayerAction.RightWallJump); newEvent.call(); if (newEvent.isCancelled) { return; } player.velocity = Vector2.zero; player.AddForce((Vector2.up + Vector2.left) * behaviour.wallJumpImpuls, ForceMode2D.Impulse); }
void doSlide(Vector2 boost) { PlayerActionEvent newEvent = new PlayerActionEvent(this, PlayerAction.Slide); newEvent.call(); if (newEvent.isCancelled) { return; } player.AddForce(boost * behaviour.slidingImpuls, ForceMode2D.Impulse); // push player once isSliding = true; }
void onPlayerAction(PlayerActionEvent cEvent) { if (cEvent.isCancelled) { return; } if (cEvent.action != PlayerAction.Jump || !cEvent.player.getRigidbody().IsTouching(trigger)) { return; } cEvent.isCancelled = true; bounce(cEvent.player.getRigidbody()); }
public static void AddEvent(PlayerActions action, PlayerActionEvent actionEvent) { if (events[action].Contains(actionEvent)) { return; } int index = events[action].FindIndex(i => actionEvent.ThisType == i.AfterThis); if (index != -1) { events[action].Insert(index, actionEvent); return; } events[action].Add(actionEvent); }
protected override void InitEvents() { onKill = this.NewPlayerActionEvent(() => { // Check Corpse Spawner var corpseSpawner = PlayerStats.Inst.KilledMob.GetComponent <CorpseSpawner>(); if (corpseSpawner == null) { return; } // Add Corpse Count corpsesToAbsorb += corpseSpawner.CorpseCount; // On Corpse Absorb corpseSpawner.SetCorpseMode(eCorpseSpawnMode.Absorb, coprpsePrefab => { if (!IsActive) { return; } corpsesToAbsorb--; coprsePrefabs.Add(coprpsePrefab); // Add Shield PlayerStats.Inst.GetShieldAt(shieldIndex).ModFlat += shieldGainPerKill; // Show Visual Effect shieldEffect.SetActive(true); }); }); onShieldChanged = this.NewPlayerActionEvent(() => { // Check Shield Health if (PlayerStats.Inst.GetShieldAt(shieldIndex).IsMin) { // Hide Visual Effect shieldEffect.SetActive(false); } }); }
private void Start() { onKill = this.NewPlayerActionEvent(() => { if (PlayerStats.Inst.CurAttackData.HasValue && PlayerStats.Inst.CurAttackData.Value.damageDealer == gameObject) { var dropTable = PlayerStats.Inst.KilledMob.GetComponent <Mob_DropItem>(); if (dropTable == null) { return; } dropTable.add_drop_table(ItemDB.Inst.GetItemPrefab <FrozenSoul>(), 100f, new RangeInt() { min = 1, max = 1 }); } }); PlayerActionEventManager.AddEvent(PlayerActions.Kill, onKill); }
protected override void InitEvents() { onHit = this.NewPlayerActionEvent(() => PlayerStats.Inst.DamageToDeal = 99999); }
public void Handler(Event he) { if (he.GetCode() == Events.Code_PlayerActionEvent) { PlayerActionEvent e = (PlayerActionEvent)he; if (e.Action == PlayerActionEvent.Actions.Chat) { string message = (string)e.Data[0]; if (message[0] == '/') { if (IsOwner(e.Player.Name)) { e.Player.SendChatMessage( ConsoleReader.HandleCommand(message.Substring(1).Split(' '), e.Player.Name) ); e.Cancelled = true; } } } if (e.Action == PlayerActionEvent.Actions.Born) { if (IsOwner(e.Player.Name)) { Server.Log("Player {0} owner is!", e.Player.Name); } } } if (he.GetCode() == Events.Code_ConsoleCommandEvent) { ConsoleCommandEvent e = (ConsoleCommandEvent)he; if (e.Command.Length > 1) { if (e.Command[0] == "addowner" && !IsOwner(e.Command[1])) { AddOwner(e.Command[1]); e.Metadata = "New owner " + e.Command[1]; Server.BroadcastMessage(e.Metadata); e.Cancelled = true; } if (e.Command[0] == "removeowner" && !IsOwner(e.Command[1])) { RemoveOwner(e.Command[1]); e.Metadata = "Deleted owner " + e.Command[1]; Server.BroadcastMessage(e.Metadata); e.Cancelled = true; } } } }
private void Start() { pAction = this.GetComponent <PlayerActionEvent>(); }
private bool Tick() { if (lockCount > 0) { return(false); } Actor actor = Queue[0]; if (actor == null) { return(false); } if (currentActorRemoved) { currentActorRemoved = false; return(true); } while (actor.Energy > 0) { Profiler.BeginSample("Scheduler: Act()"); currentActor = actor; int actionCost = actor.Act(); currentActor = null; Profiler.EndSample(); if (currentActorRemoved) { currentActorRemoved = false; return(true); } if (actionCost == 0) { UnityEngine.Debug.LogWarning( "A command with 0 energy cost was scheduled."); } SendActorDebugEvent(actor); // Handle asynchronous input by returning -1 if (actionCost < 0) { return(false); } // An action has just been done actor.Energy -= actionCost; ActionDoneEvent?.Invoke(); Profiler.BeginSample("Scheduler: Draw Dirty"); actor.Entity.Level.Draw(dirtyCells); dirtyCells.Clear(); Profiler.EndSample(); Profiler.BeginSample("Scheduler: Player"); if (actor.Control == ActorControl.Player) { FOV.RefreshFOV(player.Entity.Level, player.Entity.Cell, true); float speedFactor = actor.Speed / TurnTime; turnProgress += Mathf.FloorToInt(actionCost / speedFactor); if (turnProgress >= TurnTime) { int turnsPassed = turnProgress / TurnTime; turns += turnsPassed; turnProgress %= TurnTime; for (int i = 0; i < turnsPassed; i++) { ClockTickEvent?.Invoke(); } TimeChangeEvent?.Invoke(turns); } // Signals a successful player action to HUD PlayerActionEvent?.Invoke(actor.Energy); } Profiler.EndSample(); // Action may have added a lock if (lockCount > 0) { return(false); } } // Give the actor their speed value's worth of energy back actor.Energy += actor.Speed; // Update HUD again to reflect refill if (actor.Control == ActorControl.Player) { PlayerActionEvent?.Invoke(actor.Energy); } Actor dequeued = Queue[0]; Queue.RemoveAt(0); Queue.Add(dequeued); return(true); }