Пример #1
0
 public void setPause()
 {
     paused                  = true;
     Time.timeScale          = 0.0f;
     cannon.collider.enabled = false;
     bulletPrefab.GetComponent <Bullet>().enabled = false;
     //enemyPrefab.GetComponent<Enemy>().enabled = false;
     //cannonPrefab.GetComponent<Cannon>().enabled = false;
     this.GetComponent <LevelManager>().enabled = false;
 }
Пример #2
0
    public void InitializeObjects()
    {
        cannon      = (OTAnimatingSprite)GameObject.Instantiate(cannonPrefab);
        cannon.name = "cannon";
        cannon.GetComponent <Cannon>().setBombs(3);
        cannon.GetComponent <Cannon>().setFuel(80);

        if (!isTutorial)
        {
            //grid = (GameObject) Object.Instantiate(gridPrefab);
            //grid.name = "grid";
        }
    }
Пример #3
0
    private IEnumerator playResultAnimation(OTAnimatingSprite anim, string soundName)
    {
        //Debug.Log ("Started Playing");
        anim.GetComponent<Renderer>().enabled = true;
        anim._numberOfPlays = 1;
        anim.Play();
        OTSound sound = new OTSound(soundName);
        sound.Play();
        //Debug.Log("Funcion delay");
        yield return new WaitForSeconds(1f);

        //Debug.Log ("finished Playing");
        anim.GetComponent<Renderer>().enabled = false;
    }
Пример #4
0
    public void Add(float x, float y, bool immediate = false)
    {
        OTAnimatingSprite firefly = (OTAnimatingSprite)OT.CreateSprite("Firefly");

        firefly.gameObject.SetActive(true);
        firefly.transform.parent        = this.transform;
        firefly.transform.localPosition = new Vector3(x, y, 0f);

        fireflies.Add(firefly);
        if (immediate)
        {
            firefly.GetComponent <Firefly>().immediate = true;
        }
    }
Пример #5
0
    // Use this for initialization
    void Start()
    {
        OT.view.position = new Vector2(0.0f, 900f);
        Camera.mainCamera.GetComponent <FadeController>().FadeIn(Time.time, 2f);

        Rect pos = new Rect(Screen.width / 2 - 300f, Screen.height / 2 - 32f, 600f, 64f);

        Color color = new Color(1f, 1f, 1f);

        style                  = new GUIStyle();
        style.alignment        = TextAnchor.MiddleCenter;
        style.normal.textColor = color;

        allDialog.Add(new Dialog(pos, "Good work, son.", color, style, Time.time, 5.0f + Time.time));
        allDialog.Add(new Dialog(pos, "End.", color, style, Time.time + 5.0f, 10000000.0f + Time.time));

        firefly = (OTAnimatingSprite)OT.CreateSprite("Firefly");
        firefly.GetComponent <Firefly>().enabled = false;
        firefly.depth = -100;
        firefly.size  = new Vector2(32f, 32f);
        firefly.pivot = OTObject.Pivot.Center;
        firefly.PlayLoop("right");
    }
Пример #6
0
    // Update is called once per frame
    void Update()
    {
        //if (playing) {
        if (!paused)
        {
            scoreText.text  = "Score: " + score;
            shieldText.text = "Shield: " + cannon.GetComponent <Cannon>().getShield();
            if (cannon.GetComponent <Cannon>().getShield() == 100)
            {
                shieldText.color = Color.green;
            }
            else if (cannon.GetComponent <Cannon>().getShield() == 0)
            {
                shieldText.color = Color.red;
            }
            else
            {
                shieldText.color = Color.white;
            }
            fuelText.text = "Fuel: " + cannon.GetComponent <Cannon>().getFuel();
            if (cannon.GetComponent <Cannon>().getFuel() == 60)
            {
                fuelText.color = Color.green;
            }
            else if (cannon.GetComponent <Cannon>().getFuel() == 0)
            {
                fuelText.color = Color.red;
            }
            else
            {
                fuelText.color = Color.white;
            }
            bombsText.text = "Bombs: " + bombCount;
            if (bombCount == 3)
            {
                bombsText.color = Color.green;
            }
            else if (bombCount == 0)
            {
                bombsText.color = Color.red;
            }
            else
            {
                bombsText.color = Color.white;
            }

            if (Time.realtimeSinceStartup == 162)
            {
                foreach (OTSprite enemyy in enemiesInGame)
                {
                    enemyy.GetComponent <Enemy>().setMaxSpeed(2);
                }
            }
            if (Time.realtimeSinceStartup == 202)
            {
                foreach (OTSprite enemyy in enemiesInGame)
                {
                    enemyy.GetComponent <Enemy>().setMaxSpeed(5);
                }
            }

            /*} else {
             *      // game over here
             * }
             */
            if (bombLaunched)
            {
                //	this.GetComponent<LevelManager>().enabled=false;
                if (Time.frameCount - numFrameAtLaunch < 40)
                {
                    if (!isLocking)
                    {
                        foreach (OTSprite enemy in enemiesInGame)
                        {
                            enemy.GetComponent <Enemy>().setGravity(0.00001f);
                            enemy.GetComponent <Enemy>().setMaxSpeed(0.01f);
                        }
                        isLocking = true;
                    }
                    cannon.GetComponent <Cannon>().setArmor((int)(Time.frameCount - numFrameAtLaunch) / 5 + 1);
                }
                if (Time.frameCount - numFrameAtLaunch == 40)
                {
                    this.audio.PlayOneShot(Charge);
                }
                if (Time.frameCount - numFrameAtLaunch > 40 && Time.frameCount - numFrameAtLaunch < 80)
                {
                    cannon.transform.Translate(Mathf.Sin(Time.frameCount * 20), 0, 0);
                }

                if (Time.frameCount - numFrameAtLaunch > 80)
                {
                    if (enemiesInGame.Count == 0)
                    {
                        if (!isTutorial)
                        {
                            this.GetComponent <LevelManager>().enabled = true;
                        }
                        bombLaunched = false;
                        isLocking    = false;
                        cannon.GetComponent <Cannon>().setArmor(0);
                    }
                    for (int i = 0; i < enemiesInGame.Count; ++i)
                    {
                        destroyEnemy(enemiesInGame[i], true);
                    }
                }
            }
        }
    }
Пример #7
0
	// Update is called once per frame
	void Update () {
		Vector3 moveRequest = new Vector3();
		
		moveRequest = new Vector3(Input.GetAxisRaw("Horizontal"), 0.0f, 0.0f);
		WalkDirection direction = currentWalkDirection;

		if (moveRequest.sqrMagnitude > 0.0) {
			moveRequest.Normalize();
			
			if (moveRequest.x > 0) {
				direction = WalkDirection.RIGHT;
			} else {
				direction = WalkDirection.LEFT;
			}	
		}
		
		if(Input.GetKeyDown(KeyCode.Z) && !isCurrentlySwinging) {
			isCurrentlySwinging = true;
			
			OTAnimatingSprite sprite = GetComponent<OTAnimatingSprite>();
			if(direction == WalkDirection.LEFT) {
				sprite.PlayOnce("catchLeft");
			} else {
				sprite.PlayOnce("catchRight");
			}
			sprite.Play();
			sprite.onAnimationFinish = OnSwingDone;
		}
		
		if(isCurrentlySwinging) {
			float netXCoord;
			if(direction == WalkDirection.LEFT) {
				netXCoord = -64.0f;
			} else {
				netXCoord = 24.0f;
			}
				
			Rect net = new Rect(this.transform.position.x + netXCoord, this.transform.position.y - 30f, 40f, 60f);
			
			bool captured = fireflies.Captures(net);
			if(captured) {
				Debug.Log ("Got one!");
				pickupSound.Play();
				
				OTAnimatingSprite firefly = (OTAnimatingSprite) OT.CreateSprite("Firefly");
				firefly.GetComponent<Firefly>().enabled = false;
				firefly.depth = -100;
				firefly.size = new Vector2(64f, 64f);
				firefly.pivot = OTObject.Pivot.BottomLeft;
				firefly.PlayLoop("right");
				
				uiFireflies.Add (firefly);
				
				OnSwingDone(null);
			}
		}
		
		moveRequest *= Time.deltaTime * moveSpeed;
		
		bool wasFalling = falling;
		falling = terrain.CanMoveTo(this.transform.localPosition.x, this.transform.localPosition.y - 1.2f, collidingBox);
		
		if(!falling && !terrain.CanMoveTo(this.transform.localPosition.x + moveRequest.x * 10f, this.transform.localPosition.y - 1.2f, collidingBox)) {
			lastJumpPos = this.transform.localPosition;
			lastJumpCount = uiFireflies.Count;
		}
		

		moveRequest = terrain.Move(this.transform.localPosition, collidingBox, moveRequest);
		this.transform.Translate(moveRequest);
		
		
		if(wasFalling && !falling) {
			landSound.Play();
		}
		
		if(!falling && verticalSpeed < 0f) {
			verticalSpeed = 0f;
			
			if(Input.GetKeyDown(KeyCode.Space)) {
				jumpSound.Play();
				verticalSpeed = jumpSpeed;
			}
		}
		
		Fall();
		UpdateAnimation(moveRequest.sqrMagnitude > 0.0, direction);
		
		currentWalkDirection = direction;
		
		UpdateDialog();
		
		UpdateEvents();
		
		UpdateUISprites();
		
		if(this.transform.localPosition.y < 100) {
			this.transform.localPosition = lastJumpPos;
			while(uiFireflies.Count > lastJumpCount) {
				uiFireflies.RemoveAt(0);
			}
		}

	}