IEnumerator HoldWalkControls() { WalkButtonControl temp = GameObject.Find("Canvas/ControlsPanel/PlayPanel/SprintButton").GetComponent <WalkButtonControl>(); temp.interactable = false; yield return(new WaitForSeconds(2)); temp.interactable = true; }
// Start is called before the first frame update void Start() { anim = GetComponent <Animator>(); animator = GetComponent <Animator>(); walkButtonControl = GameObject.Find("Canvas/ControlsPanel/PlayPanel/SprintButton").GetComponent <WalkButtonControl>(); js = GameObject.Find("Canvas/ControlsPanel/PlayPanel/VariableJoystick/Background/Handle").transform; shootButtonControl = GameObject.Find("Canvas/ControlsPanel/ShooterPanel/ShootButton").GetComponent <WalkButtonControl>(); jsposF = js.position; speed = 0.05f; jsangle = 0; jsmag = 0; basicDir = Playerprefs.playerPos; isColliding = 1; collisionAngle = 0; }
// Start is called before the first frame update void Start() { BombTypePanel = GameObject.Find("Canvas/ControlsPanel/BomberPanel/BombTypePanel").GetComponent <CanvasGroup>(); buttonControl = GameObject.Find("Canvas/ControlsPanel/BomberPanel/PlantButton").GetComponent <WalkButtonControl>(); landMineButton = GameObject.Find("Canvas/ControlsPanel/BomberPanel/BombTypePanel/MineButton").GetComponent <Button>(); timerBombButton = GameObject.Find("Canvas/ControlsPanel/BomberPanel/BombTypePanel/TimerButton").GetComponent <Button>(); closeButton = GameObject.Find("Canvas/ControlsPanel/BomberPanel/BombTypePanel/CloseButton").GetComponent <Button>(); PlayPanel = GameObject.Find("Canvas/ControlsPanel/PlayPanel").GetComponent <CanvasGroup>(); bombPrefab = Resources.Load <GameObject>("Bomb"); animator = GetComponent <Animator>(); trigger = true; tempScript = gameObject.GetComponent <CharacterScript>(); landMineButton.onClick.AddListener(delegate { plantBomb(0); }); timerBombButton.onClick.AddListener(delegate { plantBomb(1); }); closeButton.onClick.AddListener(delegate { closeButtonAction(); }); }
// Start is called before the first frame update void Start() { buttonControl = GameObject.Find("Canvas/ControlsPanel/ShooterPanel/ShootButton").GetComponent <WalkButtonControl>(); animator = GetComponent <Animator>(); trigger = true; }
// Start is called before the first frame update void Start() { buttonControl = GameObject.Find("Canvas/ControlsPanel/CollectorPanel/StoreButton").GetComponent <WalkButtonControl>(); }
// Update is called once per frame void FixedUpdate() { if (walkButtonControl == null) { walkButtonControl = GameObject.Find("Canvas/ControlsPanel/PlayPanel/SprintButton").GetComponent <WalkButtonControl>(); } if (js == null) { js = GameObject.Find("Canvas/ControlsPanel/PlayPanel/VariableJoystick/Background/Handle").transform; } if (shootButtonControl == null) { shootButtonControl = GameObject.Find("Canvas/ControlsPanel/ShooterPanel/ShootButton").GetComponent <WalkButtonControl>(); } shootAl = !shootButtonControl.pressed; deltaTime = Time.deltaTime; jspos = jsposF - (Vector2)js.position; if (jspos != new Vector2(0, 0) && shootAl) { jsangle = (Mathf.Atan2(jspos.x, jspos.y) * Mathf.Rad2Deg); if (walkButtonControl.pressed) { jsmag = Mathf.Sqrt(Mathf.Pow(jspos.x, 2) + Mathf.Pow(jspos.y, 2)); } else { jsmag = 0; } } else { jsangle = 0; jsmag = 0; } if (anim.GetCurrentAnimatorStateInfo(0).IsName("Gunplay")) { jsmag = 0; } /*if (Input.GetKey("3")) * { * jsmag = 1.5f * jsmag; * } * * if (Input.GetKeyDown("1")) * { * if (shootAl) * { * jsmag = 0; * anim.SetTrigger("shoot"); * anim.SetTrigger("plantBomb"); * StartCoroutine(BulletDrop()); * shootAl = false; * } * } * * if (Input.GetKey("1")) * { * jsmag = 0; * } * * if (Input.GetKeyUp("1")) * { * shootAl = true; * }*/ Vector3 vecrot = transform.eulerAngles; if (jsangle != 0) { if (basicDir == -1) { vecrot.y = jsangle; } else { vecrot.y = jsangle + 180; } } else { if (basicDir == -1) { vecrot.y = 180; } else { vecrot.y = 0; } } transform.eulerAngles = vecrot; if (jsmag > 20) { anim.SetFloat("speed", 1); } else { anim.SetFloat("speed", 0); } if (collisionAngle - jsangle > 10 || collisionAngle - jsangle < -10) { isColliding = 1; } Vector3 vec = transform.position; vec.z = vec.z + Mathf.Cos((transform.eulerAngles.y * Mathf.PI) / 180) * jsmag * speed * Time.deltaTime * isColliding; vec.x = vec.x + Mathf.Sin((transform.eulerAngles.y * Mathf.PI) / 180) * jsmag * speed * Time.deltaTime * isColliding; rb.MovePosition(vec); }