private void Start() { MV = GetComponent <General.MoveAnimation>(); LS = GetComponent <General.ListAnimation>(); if (Bullet == null) { Debug.Log("Shooting nothing!"); } //if (ammo > 0) { Reload(); } }
private void Start() { G = GetComponent <Gun>(); MV = GetComponent <General.MoveAnimation>(); EX = GetComponentInChildren <General.Extender>(); if (MV == null) { Debug.Log("No mv for meleegun " + gameObject.name); } //LS = GetComponent<General.ListAnimation>(); //RB = GetComponent<Rigidbody2D>(); Dzones = new List <Collider2D>(); foreach (Transform c in transform) { Collider2D[] ct = c.GetComponents <Collider2D>(); if (ct != null) { for (int i = 0; i < ct.Length; i++) { if (ct[i].isTrigger) { Dzones.Add(ct[i]); } } } } if (Dzones.Count == 0) { Dzones = null; Debug.Log("No DZ for " + gameObject.name); } if (!active) { DisableAttacks(); } //GetComponentInChildren<Collider2D>(); }
private void Ejection(Transform c) //Launch and propel the module out of existance. (Don't actually) (Ok maybe just a little) { if (c.CompareTag("Monster") == false) { return; } Rigidbody2D crb = c.GetComponent <Rigidbody2D>(); General.MoveAnimation cMV = c.GetComponent <General.MoveAnimation>(); if (cMV != null) { Destroy(cMV); } //if (Random.Range(0, 2) == 0) { c.gameObject.layer = 8; }//To debrisFX layer c.parent = null; if (crb == null) { crb = c.gameObject.AddComponent <Rigidbody2D>(); } crb.gravityScale = 5; crb.mass = 10; crb.drag = 2; crb.AddForce(new Vector2(0, 300), ForceMode2D.Impulse); }
//public bool allowaiming = true; //For melee weapons private void Update() { if (Input.GetKeyDown(jumpkey)) { H.Jump(jumpforce); } if (Input.GetKeyDown(actionbutton)) { DoAction(); } if (Input.GetKeyDown(dropkey)) { H.ReturnItem(); } if (Input.GetMouseButton(0)) { DoButtonAction(); } if (Input.GetKeyDown("q")) { H.HoldNextItem(true); } if (Input.GetKeyDown("e")) { H.HoldNextItem(); } #region Movement and Aiming float axis = Input.GetAxis("Horizontal"); if (axis != 0) { if (Input.GetKeyDown(runbutton)) { running = true; } if (running) { if (H.Move(moveforce * axis * 2)) { H.DoAnimation(2, true); } } else { if (H.Move(moveforce * axis, allowflip)) { H.DoAnimation(1, true); } } } else { running = false; } //endElse General.MoveAnimation MV = null; if (H.HeldItem != null) { MV = H.HeldItem.GetComponent <General.MoveAnimation>(); //This is pretty bad - make it event dependent if (MV != null && MV.AniIndex > 0) { return; } //allowaiming = false; } else { allowaiming = true; } float torot = Menu.UsefulStuff.MouseToPointRotation(H.HeldItem.transform.position); //FOR torot -90 to 90 When !flip 90 to -90(up) When flip 270 to 90(up) float htorot = Menu.UsefulStuff.MouseToPointRotation(transform.position); //FOR htorot !flip -90(up) 90(down) | flip -90(up) -180to90(down) //Debug.Log(htorot); //torot += 180f; if (H.HeldItem.GetComponent <Rigidbody2D>() == null) { torot = 0; } if (H.flip) { if (Mathf.Abs(htorot) > 90) { allowflip = false; H.HeldItem.rotation = Quaternion.Euler(0, 0, torot + 180); } else { if (H.flip) { if (!running) { allowflip = true; H.Move(-1); //Debug.Log("Flippin out"); allowflip = false; } } } } else { if (Mathf.Abs(htorot) < 90) { allowflip = false; H.HeldItem.rotation = Quaternion.Euler(0, 0, torot); } else { if (!H.flip) { if (!running) { allowflip = true; //Debug.Log("Unflippin out"); H.Move(1); allowflip = false; } } } } } else { allowflip = true; } //else // { // if (H.HeldItem != null) { }//H.HeldItem.rotation = Quaternion.Euler(0, 0, 0); } //} #endregion }