public void mh_MouseDownEvent(object sender, MouseEventArgs e) { LogHelper.ShowLog("鼠标按键 {0}", e.Button.ToString()); if (e.Button == MouseButtons.Left) { LogHelper.ShowLog("按下了左键"); mouseStatus.leftDown = true; // 判断是否需要压枪 if (player.runLogic) { // 判断是否开镜 // 常规开镜 if (jichuViewModel.KaiJingMeth) { // 判断射击模式 // TODO 同步验证是否需要延迟验证 Task.Run(() => { Thread.Sleep(10); FireLogic.ValiShoot(globalParam, player); FireLogic.OpenFire(); }); } else { // 快速开镜 异步延迟检查是否为开镜射击射击 player.isShoot = true; Task.Run(() => { Thread.Sleep(100); FireLogic.ValiShoot(globalParam, player); }); Task.Run(() => { FireLogic.OpenFire(); }); } } // TODO 执行相关逻辑 } else if (e.Button == MouseButtons.Right) { LogHelper.ShowLog("按下了右键"); mouseStatus.rightDown = true; } else if (e.Button == MouseButtons.XButton1) { player.autoShoot = true; LogHelper.ShowLog("自动射击"); Task.Run(() => { FireLogic.AutoShoot(); }); } startPoint = e.Location; }
IEnumerator DestroyFireTile(FireLogic script) { yield return(new WaitForEndOfFrame()); script.AddScore(); if (script.parentTilemap) { script.parentTilemap.SetTile(script.tilemapPos, null); } }
public override bool StartUp(Vector3Int position, ITilemap tilemap, GameObject go) { // Streangly the position of gameobject starts at Left Bottom point of cell and not at it center if (go) { go.transform.position += Vector3.up * 0.5f + Vector3.right * 0.5f; FireLogic script = prefab.GetComponent <FireLogic>(); Tilemap tm = tilemap.GetComponent <Tilemap>(); script.parentTilemap = tm; } return(base.StartUp(position, tilemap, go)); }
private void OnTriggerStay2D(Collider2D other) { if (other.CompareTag("Fire")) { FireLogic script = other.gameObject.GetComponent <FireLogic>(); if (script && script.parentTilemap) { StartCoroutine(DestroyFireTile(script)); } else { Destroy(other); } } }