コード例 #1
0
	void Awake () {
		gameObject.tag = "Player";

		startingPosition = gameObject.transform.position;

		nextAction = 0.0f;
		activeTimer = 0.0f;

		shootCycle = ButtonCycle.open;
	}
コード例 #2
0
	void Update () {
		switch (shootCycle) {
		case ButtonCycle.open:
			if(Input.GetButton (firstAction))
				shootCycle = ButtonCycle.pressed;
			break;
		case ButtonCycle.pressed:
			if(!Input.GetButton (firstAction))
				shootCycle = ButtonCycle.released;
			break;
		case ButtonCycle.released:
			Transform bullet = Instantiate (bulletPrefab, gameObject.transform.position + new Vector3 (factor.x/Mathf.Abs(factor.x), 0, 0), gameObject.transform.rotation) as Transform;
			bullet.GetComponent<BulletController>().setDirection(direction);
			shootCycle = ButtonCycle.open;
			break;
		}

		if (Input.GetButton (secondAction) && Time.time > nextAction) {
			nextAction = Time.time + cooldown;
			activeTimer = activeDuration;
			grow ();
		}

		if (Input.GetButton (thirdAction) && Time.time > nextAction) {
			nextAction = Time.time + cooldown;
			activeTimer = activeDuration;
			shrink ();
		}

		if (activeTimer < 0) { 
			transform.localScale = Vector3.one; // Reset active ability
		} else
			activeTimer -= Time.deltaTime;
	}