Example #1
0
    public void Setup()
    {
        base.Setup();
        type = typeList.Bird;

        GameEventManager.GameStart += GameStart;
        GameEventManager.GameOver += GameOver;
        GameEventManager.Respawn += Respawn;
        if (brickPath != null)
        {
            brickPath.relatedBrick.Add(this);
        }
        else
        {
            Debug.Log("The path of "+gameObject.name+" is missing.");
        }
        setupPath();
        if ( FETool.findWithinChildren(gameObject, "Waves") != null)
        {
            Waves = FETool.findWithinChildren(gameObject, "Waves");
            WavesSpr = Waves.GetComponentInChildren<OTAnimatingSprite>();
            WavesSpr.alpha = 0f;
        }
        InvokeRepeating("turnUpdate", 0f, 0.1f);
        sprite = FETool.findWithinChildren(gameObject, "Sprite");
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        anim = this.gameObject.GetComponent <OTAnimatingSprite>();
        anim.Play();

        //DontDestroyOnLoad(this.gameObject);
    }
Example #3
0
    // This method will explode an asteroid

    public void Explode(OTObject o, CBullet3 bullet)
    {
        // Determine how many debree has to be be created
        int blocks = 2 + (int)Mathf.Floor(Random.value * 2);

        // Create debree
        for (int b = 0; b < blocks; b++)
        {
            // Shrink asteroid's rect to act as the random position container
            // for the debree
            Rect r = new Rect(
                o.rect.x + o.rect.width / 4,
                o.rect.y + o.rect.height / 4,
                o.rect.width / 2,
                o.rect.height / 2);
            // Create a debree that is relatively smaller than the asteroid that was detroyed
            OTAnimatingSprite a = RandomBlock(r, 0.6f, 0.75f, o);

            // Add this debree to the bullet telling the bullet to ignore this debree
            // in this update cycle - otherwise the bullet explosions could enter some
            // recursive 'dead' loop creating LOTS of debree
            bullet.AddDebree(a);
            // Recusively explode 2 asteroids if they are big enough, to get a nice
            // exploding debree effect.
            if (b < 2 && a.size.x > 30)
            {
                Explode(a, bullet);
            }
        }
        // Notify that this asteroid has to be destroyed
        OT.DestroyObject(o);
    }
Example #4
0
	private void UpdateAnimation(bool moving, WalkDirection direction) {
		OTAnimatingSprite sprite = GetComponent<OTAnimatingSprite>();

		if(isCurrentlySwinging) {
			return;
		}
				
		if(moving && currentWalkDirection != direction) {
			if(direction == WalkDirection.LEFT) {
				sprite.PlayLoop("walkLeft");
			} else {
				sprite.PlayLoop("walkRight");
			}
		}
		
		if(moving) {
			if(!sprite.isPlaying) {
				sprite.Play();
			}
		} else {
			sprite.Pauze();
			sprite.frameIndex = 1;
			if (direction == WalkDirection.LEFT) {
				sprite.frameIndex += 4;
			}
		}
		
		if(falling) {
			sprite.Pauze();
			sprite.frameIndex = 0;
			if (direction == WalkDirection.LEFT) {
				sprite.frameIndex += 4;
			}
		}
	}
Example #5
0
 public void LateSetup()
 {
     base.Setup();
     transform.position = new Vector3(transform.position.x, transform.position.y, 0f);
     type = typeList.Chainsaw;
     Invert = FETool.findWithinChildren(gameObject, "Inversion").GetComponentInChildren<OTAnimatingSprite>();
 }
Example #6
0
    public void Setup(LevelManager _lev)
    {
        _spr = FETool.findWithinChildren(gameObject, "TheGate").GetComponentInChildren<OTSprite>();
        _levMan = _lev;
        GameEventManager.Respawn += Respawn;
        GameEventManager.GameOver += GameOver;

        firstStep = FETool.findWithinChildren(gameObject, "ExitLoc/1");
        secondStep = FETool.findWithinChildren(gameObject, "ExitLoc/2");
        thirdStep = FETool.findWithinChildren(gameObject, "ExitLoc/3");

        spriteFirstStep = firstStep.GetComponentsInChildren<OTSprite>();
        spriteSecondStep = secondStep.GetComponentsInChildren<OTSprite>();
        spriteThirdStep = thirdStep.GetComponentsInChildren<OTSprite>();

        fadeSprites(spriteFirstStep, 0f);
        fadeSprites(spriteSecondStep, 0f);
        fadeSprites(spriteThirdStep, 0f);

        for (int i = 0 ; i < 24 ; i++)
        {
            slotList.Add(FETool.findWithinChildren(gameObject, "Slots/" + (i+1).ToString()));
        }
        defaultSlot = FETool.findWithinChildren(gameObject, "Slots/Default");

        Vortex = FETool.findWithinChildren(gameObject, "Vortex").GetComponentInChildren<OTAnimatingSprite>();
    }
 // The OnAnimationFinish delegate will be called when an animation or
 // animation frameset finishes playing.
 public void OnAnimationFinish(OTObject owner)
 {
     if (owner == animateMe)
     {
         animateMe = null;
         animating = false;
     }
 }
    void AnimateOnce()
    {
        Debug.Log("animating");
        GameObject animateObj = OT.CreateObject("fireball");

        animateMe = animateObj.GetComponent("OTAnimatingSprite") as OTAnimatingSprite;
        animateMe.PlayOnce("fire");
    }
Example #9
0
		void Start () {
				
        mySprite = GameObject.Find("Boy").GetComponent<OTAnimatingSprite>();
				
		Debug.Log(mySprite);
						
	
	}
Example #10
0
    // Use this for initialization
    void Start()
    {
        sprite = GetComponent<OTSprite>();
        gunAnimation = GetComponent<OTAnimatingSprite>();
        bang = bangGameObject.GetComponent<ParticleSystem>();

        gunAnimation.onAnimationFinish = shoot;
    }
Example #11
0
    // Create all objects for the 'walking man' stage
    void WalkingBlueManStage()
    {
        // To create the background lets create a filled sprite object
        back = OT.CreateObject(OTObjectType.FilledSprite).GetComponent <OTFilledSprite>();
        // Set the image to our wyrmtale tile
        back.image = whiteTile;
        // But this all the way back so all other objects will be located in front.
        back.depth = 1000;
        // Set material reference to 'custom' green material - check OT material references
        back.materialReference = "green";
        // Set the size to match the screen resolution.
        back.size = new Vector2(Screen.width, Screen.height);
        // Set the fill image size to 50 x 50 pixels
        back.fillSize = new Vector2(50, 50);

        // To create the walking man animation we first will have to create a sprite sheet
        OTSpriteSheet sheet = OT.CreateObject(OTObjectType.SpriteSheet).GetComponent <OTSpriteSheet>();

        // Link our walking man frames
        sheet.texture = walkingManAnimation;
        // specify the number or column and rows (frames) of this container
        sheet.framesXY = new Vector2(15, 8);

        // The next step is to create our animation object that will hold all
        // animation framesets (8 directions of walking) for our walking man
        OTAnimation animation = OT.CreateObject(OTObjectType.Animation).GetComponent <OTAnimation>();

        // Initialize our animation framesets so it can hold 8 framesets
        animation.framesets = new OTAnimationFrameset[8];
        // Add the 8 direction framesets
        animation.framesets[0] = WalkingFrameset("down", 1, sheet);
        animation.framesets[1] = WalkingFrameset("downLeft", 2, sheet);
        animation.framesets[2] = WalkingFrameset("left", 3, sheet);
        animation.framesets[3] = WalkingFrameset("upLeft", 4, sheet);
        animation.framesets[4] = WalkingFrameset("up", 5, sheet);
        animation.framesets[5] = WalkingFrameset("upRight", 6, sheet);
        animation.framesets[6] = WalkingFrameset("right", 7, sheet);
        animation.framesets[7] = WalkingFrameset("downRight", 8, sheet);
        // Give our animation a name
        animation.name = "walking-animation";

        // To put our walking man on screen we create an animting sprite object
        man = OT.CreateObject(OTObjectType.AnimatingSprite).GetComponent <OTAnimatingSprite>();
        // Set the size of our walking man
        man.size = new Vector2(40, 65);
        // Link our animation
        man.animation = animation;
        // Lets play a single frameset .. we start with 'down'
        man.animationFrameset = "down";
        // Auto-start to play this animation frameset
        man.playOnStart = true;
        // Give our sprite a name
        man.name = "man";

        // INFO : In this class Update() method, we will check the location of
        // the mouse pointer and play the corresponding direction animation
        // as we will set the right scroll speed for our background.
    }
    public void SetParemeters(OTObject shooter, float damage)
    {
        _AOE = GetComponent<OTAnimatingSprite>();
        _AOE.onCollision = OnCollision;
        _shooter = shooter;
        _damage = damage;

        _AOE.transform.parent = AOEContainer.transform;
    }
Example #13
0
 // Use this for initialization
 public void Setup(LevelManager _lev)
 {
     levMan = _lev;
     spr = GetComponentInChildren<OTAnimatingSprite>();
     GameEventManager.GameStart += GameStart;
     GameEventManager.GameOver += GameOver;
     GameEventManager.Respawn += Respawn;
     print ("setup");
 }
Example #14
0
	void Start()
    {
		xa.alive = true;
		spawnPoint = thisTransform.position; // player will respawn at initial starting point
		
		// connect external objects
		shootParent = transform.Find("shoot parent");
		shootRenderer = GameObject.Find("shoot").renderer;
		shootSprite = GameObject.Find("shoot").GetComponent<OTAnimatingSprite>();
    }
Example #15
0
    void Start()
    {
        xa.alive   = true;
        spawnPoint = thisTransform.position;         // player will respawn at initial starting point

        // connect external objects
        shootParent   = transform.Find("shoot parent");
        shootRenderer = GameObject.Find("shoot").renderer;
        shootSprite   = GameObject.Find("shoot").GetComponent <OTAnimatingSprite>();
    }
Example #16
0
 // Use this for initialization
 public void Setup()
 {
     _animations = GameObject.Find("Frameworks/OT/Animations/player").GetComponent<OTAnimation>();
     _animSprite = GetComponentInChildren<OTAnimatingSprite>();
     _STATIC = "static";
     _WALK = "walk";
     _WALKFASTER = "walkfaster";
     _MAXWALK = "maxwalk";
     _CURR = "walk";
 }
Example #17
0
    public override void Start()
    {
        base.Start();

        _spawnPoint = characterTransform.position;

        _shootParent = transform.Find("shootParent");
        var shoot = GameObject.Find("shoot");
        _shootRenderer = shoot.renderer;
        _shootSprite = shoot.GetComponent<OTAnimatingSprite>();
    }
Example #18
0
    void Start()
    {
        mySprite = GetComponent<OTAnimatingSprite>();
        // Start the player in the left facing position.
        mySprite.Play ("runLeft");

        // These determine which direction the player is moving and if they are in motion.
        climbing = false;
        moveLeft = false;
        moveRight = false;
    }
Example #19
0
 // Use this for initialization
 void Start()
 {
     for (int i = 0; i < numStars; ++i)
     {
         OTAnimatingSprite star  = (OTAnimatingSprite)OT.CreateSprite(sprites[Random.Range(0, sprites.Length)]);
         Vector3           scale = this.transform.localScale;
         Vector3           pos   = this.transform.position;
         star.position = new Vector2(Random.Range(pos.x - scale.x, pos.x + scale.x), Random.Range(pos.y - scale.y, pos.y + scale.y));
         star.depth    = -1;
     }
 }
Example #20
0
 void Awake()
 {
     //manager = UnitManager.getInstance();
     if(animated) {
         animatingProjectileSprite = GetComponent<OTAnimatingSprite>();
         animatingProjectileSprite.onCollision = OnCollision;
         animatingProjectileSprite.Play(72);
     }else {
         projectileSprite = GetComponent<OTSprite>();
         projectileSprite.onCollision = OnCollision;
     }
 }
Example #21
0
    void Start()
    {
        Camera.main.gameObject.GetComponent <Camera>().orthographicSize = 300;
        mySprite = GameObject.Find("PLAYER").GetComponent <OTAnimatingSprite>();


        Debug.Log(mySprite);

        currentAnim = anim.parado;

        theCamera = Camera.main.gameObject;
    }
Example #22
0
 // Use this for initialization
 public void Setup(LevelManager _lm, CollectiblePlaces _place)
 {
     base.Setup(_lm);
     thisType = partType.Spawner;
     collPlace = _place;
     name = "Gatepart|" + collPlace.name + Random.Range(0,100).ToString();
     PlaceCollectibleToGo = PlacesCollect.Stargate;
     _animSpr = FETool.findWithinChildren(this.gameObject, "Part").GetComponentInChildren<OTAnimatingSprite>();
     Taken = FETool.findWithinChildren(this.gameObject, "Taken").GetComponentInChildren<OTAnimatingSprite>();
     Taken.alpha = 0f;
     Pop();
 }
Example #23
0
	void Start () {
		
		Camera.main.gameObject.GetComponent<Camera>().orthographicSize = 300;    
        mySprite = GameObject.Find("PLAYER").GetComponent<OTAnimatingSprite>();
		
		
		Debug.Log(mySprite);
		
		currentAnim = anim.parado;
		
		theCamera = Camera.main.gameObject; 
	
	}
Example #24
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";
        }
    }
Example #25
0
    // This method will create an asteroid at a random position on screen and with
    // relative min/max (0-1) size. An OTObject can be provided to act as a base to
    // determine the new size.
    OTAnimatingSprite RandomBlock(Rect r, float min, float max, OTObject o)
    {
        // Determine random 1-3 asteroid type
        int t = 1 + (int)Mathf.Floor(Random.value * 3);
        // Determine random size modifier (min-max)
        float      s = min + Random.value * (max - min);
        GameObject g = null;

        // Create a new asteroid
        switch (t)
        {
        case 1: g = OT.CreateObject("asteroid1");
            break;

        case 2: g = OT.CreateObject("asteroid2");
            break;

        case 3: g = OT.CreateObject("asteroid3");
            break;
        }
        if (g != null)
        {
            g.gameObject.active = true;
            // Find this new asteroid's animating sprite
            OTAnimatingSprite sprite = g.GetComponent <OTAnimatingSprite>();
            // If a base object was provided use it for size scaling
            if (o != null)
            {
                sprite.size = o.size * s;
            }
            else
            {
                sprite.size = sprite.size * s;
            }
            // Set sprite's random position
            sprite.position = new Vector2(r.xMin + Random.value * r.width, r.yMin + Random.value * r.height);
            // Set sprote's random rotation
            sprite.rotation = Random.value * 360;
            // Set sprite's name
            sprite.depth = dp++;
            if (dp > 750)
            {
                dp = 100;
            }
            // Return new sprite
            sprite.enabled = true;
            return(sprite);
        }
        // we did not manage to create a sprite/asteroid
        return(null);
    }
Example #26
0
    // application initialization
    void Initialize()
    {
        // Get reference to gun animation sprite
        gun = OT.ObjectByName("gun") as OTAnimatingSprite;

        // Set gun animation finish delegate
        // HINT : We could use sprite.InitCallBacks(this) as well.
        // but because delegates are the C# way we will use this technique
        gun.onAnimationFinish = OnAnimationFinish;

        CreateObjectPools();
        // set our initialization notifier - we only want to initialize once
        initialized = true;
    }
Example #27
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;
        }
    }
Example #28
0
 void OnTriggerEnter(Collider other)
 {
     if (other.name.Equals("Player"))
     {
         // Explode when the player touches it
         OTAnimatingSprite explode = Instantiate(animExplosion) as OTAnimatingSprite;
         explode.transform.position = transform.position + Vector3.up * 1f;
         explode.PlayOnce("explode");
         // Cast a damage to the player
         Player.UpdateHP(damage * -1);
         // Hide the sprite
         sprite.visible = false;
     }
 }
    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;
    }
Example #30
0
 void Start()
 {
     if (GetComponentInChildren<OTSprite>() != null)
     {
         spr = GetComponentInChildren<OTSprite>();
     }
     if (GetComponentInChildren<OTAnimatingSprite>() != null)
     {
         animSpr = GetComponentInChildren<OTAnimatingSprite>();
     }
     if (GetComponent<TextUI>() != null)
     {
         lab = GetComponentInChildren<TextUI>();
     }
 }
Example #31
0
	private void OnSwingDone(OTObject owner)
	{
		if(!isCurrentlySwinging) {
			return;
		}
		isCurrentlySwinging = false;
		
		OTAnimatingSprite sprite = GetComponent<OTAnimatingSprite>();
		if(currentWalkDirection == WalkDirection.LEFT) {
			sprite.PlayLoop("walkLeft");
		} else {
			sprite.PlayLoop("walkRight");
		}
		sprite.onAnimationFinish = null;
	}
Example #32
0
    // Use this for initialization
    void Start()
    {
        //playAnimDef();
        spriteParentsTab = gameObject.GetComponentsInChildren<Transform>();
        animWaterfall = animWater = animGround = spriteParentsTab[0].GetComponentInChildren<OTAnimatingSprite>();

        foreach (Transform spriteParent in spriteParentsTab) {
            if(spriteParent.name=="spriteParentCPWaterFall") animWaterfall = spriteParent.GetComponentInChildren<OTAnimatingSprite>();
            if(spriteParent.name=="spriteParentCPWater") animWater = spriteParent.GetComponentInChildren<OTAnimatingSprite>();
            if(spriteParent.name=="spriteParentCPGround") animGround = spriteParent.GetComponentInChildren<OTAnimatingSprite>();
        }
        animWaterfall.Play("waterfall");
        animWater.Play("water");
        animGround.Play("ground");
        animWaterfall.looping = animWater.looping = animGround.looping = true;
    }
Example #33
0
    // Use this for initialization
    public override void Start()
    {
        brickType = brickEnum.Turret;
        _base = FETool.findWithinChildren(this.gameObject, "Base");
        _maca = FETool.findWithinChildren(this.gameObject, "Maca");
        _rotating = FETool.findWithinChildren(this.gameObject, "Rotating");
        _target = FETool.findWithinChildren(this.gameObject, "Target");
        _projectile = FETool.findWithinChildren(this.gameObject, "Projectile").GetComponent<Projectile>();
        _projectile.owner = this;

        resetTurret();

        _triggerArea = FETool.findWithinChildren(this.gameObject, "TriggerArea").GetComponent<BoxCollider>();

        _baseAnim = _base.GetComponentInChildren<OTAnimatingSprite>();
        _macaAnim = _maca.GetComponentInChildren<OTAnimatingSprite>();
        _rotatingAnim = _rotating.GetComponentInChildren<OTAnimatingSprite>();
        _projectileSpr = _projectile.GetComponentInChildren<OTSprite>();

        InvokeRepeating("shootAtPoint", 0f, shootRate);
        InvokeRepeating("turn", 0f, turnRate);
        InvokeRepeating("playIdleSound", 0f, IdleSound.RepeatRate);
    }
Example #34
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");
    }
Example #35
0
    TextMesh stagemesh2;                // textmesh for stage 1 menu item

    // Create all objects fo    r the star stage by code
    void AnimatingGreenStarStage()
    {
        // To create a scrolling background, first create a filled sprite object
        back = OT.CreateObject(OTObjectType.FilledSprite).GetComponent <OTFilledSprite>();
        // Set the image to the tile texture
        back.image = whiteTile;
        // Set material reference to 'custom' blue material
        back.materialReference = "blue";
        // Set size to match the screen resolution so it will fill the entire screen
        back.size = new Vector2(Screen.width, Screen.height);
        // Set the display depth all the way back so everything else will come on top
        back.depth = 1000;
        // Set fill image size to 50 x 50 pixels
        back.fillSize = new Vector2(50, 50);
        // Set scroll speed so we will scroll horizontally 20 px / second
        back.scrollSpeed = new Vector2(20, 0);

        // To create the animating star we first have to create the sprite sheet object that will
        // hold our texture/animation frames
        OTSpriteSheet sheet = OT.CreateObject(OTObjectType.SpriteSheet).GetComponent <OTSpriteSheet>();

        //  Give our sheet a name
        sheet.name = "mySheet";
        // Assign texture
        sheet.texture = greenStarsAnimation;
        // Specify how many columns and rows we have (frames)
        sheet.framesXY = new Vector2(25, 3);
        // Because we have some overhead space to the right and bottom of our texture we have to
        // specify the original texture size and the original frame size so that the right texture
        // scale and offsetting can be calculated.
        sheet.sheetSize = new Vector2(2048, 256);
        sheet.frameSize = new Vector2(80, 80);

        // Next thing is to create the animation that our animating sprite will use
        OTAnimation animation = OT.CreateObject(OTObjectType.Animation).GetComponent <OTAnimation>();
        // This animation will use only one frameset with all animating star frames.
        OTAnimationFrameset frameset = new OTAnimationFrameset();

        // Link up the sprite sheet to this animation's frameset
        frameset.container = sheet;
        // Frameset animation will start at frame index 0
        frameset.startFrame = 0;
        // Frameset animation will end at frame index 69
        frameset.endFrame = 69;
        // Assign this frameset to the animation.
        // HINT : by asigning more than one frameset it is possible to create an animation that will span
        // across mutiple framesets
        // HINT : Because it is possible (and very easy) to play a specific frameset of an animation
        // One could pack a lot of animations into one animation object.
        animation.framesets = new OTAnimationFrameset[] { frameset };
        // Set the duration of this animation
        // HINT : By using the OTAnimationSprite.speed setting one can speed up or slow down a
        // running animation without changing the OTAnimation.fps or .duration setting.
        animation.duration = .95f;
        // Lets give our animation a name
        animation.name = "star-animation";

        // To finally get the animatiing star on screen we will create our animation sprite object
        star = OT.CreateObject(OTObjectType.AnimatingSprite).GetComponent <OTAnimatingSprite>();
        // Link up the animation
        star.animation = animation;
        // Lets start at a random frame
        star.startAtRandomFrame = true;
        // Lets auto-start this animation
        star.playOnStart = true;
        // start invisible and make visible when containers are ready.
        star.visible         = false;
        star.name            = "star";
        star.spriteContainer = sheet;

        // INFO : This animation 'star' will be center (0,0) positioned and act as a prototype
        // to create more moveing and animating (additive) 'stars'.
    }
Example #36
0
    // Update is called once per frame
    void Update()
    {
        // only go on if Orthello is ready
        if (!OT.isValid)
        {
            return;
        }
        // Initialize application once
        if (!initialized)
        {
            Initialize();
        }

        // if containers that were created are not ready yet, lets hold.
        if (!OT.ContainersReady())
        {
            return;
        }

        switch (appMode)
        {
        case 1:
            star.visible = true;
            // we are in the star stage so increase star creation wait time
            starTime += Time.deltaTime;
            // check if we may create a new star
            if (starTime > starSpeed)
            {
                // Lets create one, reset the wait time
                starTime = 0;
                // Create a copy of out animating star
                OTAnimatingSprite newStar = OT.CreateSprite(star) as OTAnimatingSprite;
                // Put this star in our active stars list
                stars.Add(newStar);
                // Give it a random size
                newStar.size *= (0.3f + Random.value * 2.5f);
                // Give it a random position on the right border of the screen
                newStar.position = new Vector2((Screen.width / 2) + newStar.size.x / 2,
                                               ((Screen.height / 2) * -1) + newStar.size.y / 2 + Random.value * (Screen.height - newStar.size.y));
                // Calculate the depth (smaller stars to the back, bigger to the front)
                newStar.depth = (int)((1 / newStar.size.x) * 100);
                // Set material to additive
                newStar.additive   = true;
                newStar.frameIndex = 0;
            }

            // Lets loop all active stars
            // HINT : Because we will be adjusting (removing) items as they get out of view,
            // we better not use a for() loop. While() is the better way for this.
            int s = 0;
            while (s < stars.Count)
            {
                // get next active star
                OTAnimatingSprite dStar = stars[s];
                // increase its position
                dStar.position += new Vector2(stars[s].size.x * 3 * Time.deltaTime * -1, 0);
                // If the star gets out of view we will remove and destroy it
                if (dStar.outOfView)
                {
                    // remove from active stars list
                    stars.Remove(dStar);
                    // destroy this object
                    OT.DestroyObject(dStar);
                    // no need to increment iterator as we just removed the current element
                }
                else
                {
                    s++;     // increment iterator
                }
            }
            break;

        case 2:
            man.visible = true;
            // we are in the walking man stage so calculate a normalized vector from
            // our man to the mouse pointer
            Vector2 mouseVector = (OT.view.mouseWorldPosition - man.position).normalized;
            // The Atan2 will give you a -3.141 to 3.141 range depending of your vector x/y values
            float angle = Mathf.Atan2(mouseVector.x, mouseVector.y);
            // Play the right frameset dependent on the angle
            float  part = 6.2f / 8;
            string anim = "";
            if (angle > -1 * (part / 2) && angle <= (part / 2))
            {
                anim = "up";
            }
            else
            if (angle > -3 * (part / 2) && angle <= -1 * (part / 2))
            {
                anim = "upLeft";
            }
            else
            if (angle > -5 * (part / 2) && angle <= -3 * (part / 2))
            {
                anim = "left";
            }
            else
            if (angle > -7 * (part / 2) && angle <= -5 * (part / 2))
            {
                anim = "downLeft";
            }
            else
            if (angle > (part / 2) && angle <= 3 * (part / 2))
            {
                anim = "upRight";
            }
            else
            if (angle > 3 * (part / 2) && angle <= 5 * (part / 2))
            {
                anim = "right";
            }
            else
            if (angle > 5 * (part / 2) && angle <= 7 * (part / 2))
            {
                anim = "downRight";
            }
            else
            {
                anim = "down";
            }
            man.PlayLoop(anim);
            // adjust background scroll speed related to our mouse vector
            back.scrollSpeed = mouseVector * 10;
            break;
        }

        // color menu red when we are hovering over an item
        if (OT.Over(stage1))
        {
            stagemesh1.renderer.material.color = new Color(1, .3f, .3f);
        }
        else
        {
            stagemesh1.renderer.material.color = new Color(1, 1, 1);
        }

        if (OT.Over(stage2))
        {
            stagemesh2.renderer.material.color = new Color(1, .3f, .3f);
        }
        else
        {
            stagemesh2.renderer.material.color = new Color(1, 1, 1);
        }


        //check if we want to change stage
        if (OT.Clicked(stage1))
        {
            appMode = 1;
            CreateObjects();
        }
        else
        if (OT.Clicked(stage2))
        {
            appMode = 2;
            CreateObjects();
        }
    }
Example #37
0
 // Use this for initialization
 protected void Awake()
 {
     anim = GetComponent<OTAnimation>();
     sprite = GetComponent<OTAnimatingSprite>();
     print (	sprite.animationFrameset);
 }
Example #38
0
 // application initialization
 void Initialize()
 {
     // Get reference to gun animation sprite
     gun = OT.ObjectByName("gun") as OTAnimatingSprite;
     // Set gun animation finish delegate
     // HINT : We could use sprite.InitCallBacks(this) as well.
     // but because delegates are the C# way we will use this technique
     gun.onAnimationFinish = OnAnimationFinish;
     // Create our object pool if we want.
     OT.objectPooling = true;
     if (OT.objectPooling)
         CreateObjectPools();
     // set our initialization notifier - we only want to initialize once
     initialized = true;
 }
Example #39
0
    void Start()
    {
        mySprite = GameObject.Find("Boy").GetComponent <OTAnimatingSprite>();

        Debug.Log(mySprite);
    }
Example #40
0
	void Start () {
	
		
		mySprite = GameObject.Find("PLAYER").GetComponent<OTAnimatingSprite>();
	}
Example #41
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);
			}
		}

	}
 // Use this for initialization
 protected void Awake()
 {
     anim = GetComponent<OTAnimation>();
     sprite = GetComponent<OTAnimatingSprite>();
 }
Example #43
0
 // Use this for initialization
 void Start()
 {
     sprite = transform.GetComponent<OTAnimatingSprite>();
     sprite.speed = 0;
 }
Example #44
0
 void Start()
 {
     mySprite = GameObject.Find("PLAYER").GetComponent <OTAnimatingSprite>();
 }
Example #45
0
    OTAnimatingSprite sprite; // this asteroid's sprite class

    #endregion Fields

    #region Methods

    // Use this for initialization
    void Start()
    {
        // get sprite class of this asteroid
        sprite = GetComponent<OTAnimatingSprite>();
        sheet1 = OT.ContainerByName("asteroid sheet 1") as OTSpriteSheet;
    }
Example #46
0
    // This method will add a debree object to the ignore debree list.
    // We will have to maintain a ignore debree list because if we dont,
    // this bullet can generate a 'recursive' exploding state that will
    // create LOTS and LOTS of debree, totaly hanging this application

    public void AddDebree(OTAnimatingSprite debreeObject)
    {
        debree.Add(debreeObject);
    }
Example #47
0
    // Create all objects for the 'walking man' stage
    void WalkingBlueManStage()
    {
        // To create the background lets create a filled sprite object
        back = OT.CreateObject(OTObjectType.FilledSprite).GetComponent<OTFilledSprite>();
        // Set the image to our wyrmtale tile
        back.image = whiteTile;
        // But this all the way back so all other objects will be located in front.
        back.depth = 1000;
        // Set material reference to 'custom' green material - check OT material references
        back.materialReference = "green";
        // Set the size to match the screen resolution.
        back.size = new Vector2(Screen.width, Screen.height);
        // Set the fill image size to 50 x 50 pixels
        back.fillSize = new Vector2(50, 50);

        // To create the walking man animation we first will have to create a sprite sheet
        OTSpriteSheet sheet = OT.CreateObject(OTObjectType.SpriteSheet).GetComponent<OTSpriteSheet>();
        // Link our walking man frames
        sheet.texture = walkingManAnimation;
        // specify the number or column and rows (frames) of this container
        sheet.framesXY = new Vector2(15, 8);

        // The next step is to create our animation object that will hold all
        // animation framesets (8 directions of walking) for our walking man
        OTAnimation animation = OT.CreateObject(OTObjectType.Animation).GetComponent<OTAnimation>();
        // Initialize our animation framesets so it can hold 8 framesets
        animation.framesets = new OTAnimationFrameset[8];
        // Add the 8 direction framesets
        animation.framesets[0] = WalkingFrameset("down",1, sheet);
        animation.framesets[1] = WalkingFrameset("downLeft", 2, sheet);
        animation.framesets[2] = WalkingFrameset("left", 3, sheet);
        animation.framesets[3] = WalkingFrameset("upLeft", 4, sheet);
        animation.framesets[4] = WalkingFrameset("up", 5, sheet);
        animation.framesets[5] = WalkingFrameset("upRight", 6, sheet);
        animation.framesets[6] = WalkingFrameset("right", 7, sheet);
        animation.framesets[7] = WalkingFrameset("downRight", 8, sheet);
        // Give our animation a name
        animation.name = "walking-animation";

        // To put our walking man on screen we create an animting sprite object
        man = OT.CreateObject(OTObjectType.AnimatingSprite).GetComponent<OTAnimatingSprite>();
        // Set the size of our walking man
        man.size = new Vector2(40, 65);
        // Link our animation
        man.animation = animation;
        // Lets play a single frameset .. we start with 'down'
        man.animationFrameset = "down";
        // Auto-start to play this animation frameset
        man.playOnStart = true;
        // Give our sprite a name
        man.name = "man";

        // INFO : In this class Update() method, we will check the location of
        // the mouse pointer and play the corresponding direction animation
        // as we will set the right scroll speed for our background.
    }
Example #48
0
 // Use this for initialization
 void Start()
 {
     // get sprite class of this asteroid
     sprite = GetComponent <OTAnimatingSprite>();
     sheet1 = OT.ContainerByName("asteroid sheet 1") as OTSpriteSheet;
 }
    void Awake()
    {
        // Init Gold coin size
        m_aniSpriteGoldCoin01 = GameObject.Find ("GoldCoin_01").GetComponent<OTAnimatingSprite>();
        m_aniSpriteGoldCoin02 = GameObject.Find ("GoldCoin_02").GetComponent<OTAnimatingSprite>();
        m_aniSpriteGoldCoin03 = GameObject.Find ("GoldCoin_03").GetComponent<OTAnimatingSprite>();
        m_aniSpriteGoldCoin04 = GameObject.Find ("GoldCoin_04").GetComponent<OTAnimatingSprite>();

        int l = 0;
        for (int i=0; i<13; i++)
        {
            string strAtlasName = "";

            if (i < 9)
            {
                strAtlasName = "GoldCoin_Altas_0" + (i + 1);
            }
            else
            {
                strAtlasName = "GoldCoin_Altas_" + (i + 1);
            }

            int j = GameObject.Find (strAtlasName).GetComponent<OTSpriteAtlasCocos2D>().atlasData.Length;

            for (int k=0; k<j; k++)
            {
                m_sizeOfGoldCoin[l] = GameObject.Find (strAtlasName).GetComponent<OTSpriteAtlasCocos2D>().atlasData[k].size;
                l++;
            }
        }

        // Init Gold coin position
        float[] XposCoin = new float[30]
        { 370.0f,369.0f,353.0f,343.0f,342.0f,347.0f,330.0f,325.0f,315.0f,269.0f,
            274.0f,266.0f,277.0f,198.0f,230.0f,160.0f,184.0f,222.0f,183.0f,124.0f,
            120.0f,166.0f,122.0f,87.0f,51.0f,56.0f,153.0f,149.0f,99.0f,267.0f };

        float[] YposCoin = new float[30]
        { 0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,
            0.0f,37.0f,51.0f,27.0f,62.0f,46.0f,146.0f,167.0f,179.0f,218.0f,336.0f,
            345.0f,438.0f,476.0f,459.0f,491.0f };

        for(int i=0; i<30; i++)
        {
            m_posGoldCoin[i] = new Vector2(0.0f, (YposCoin[i] * -1.0f) + (-140.0f));
        }

        // Hide the animation
        m_aniSpriteGoldCoin01.alpha = 0f;
        m_aniSpriteGoldCoin02.alpha = 0f;
        m_aniSpriteGoldCoin03.alpha = 0f;
        m_aniSpriteGoldCoin04.alpha = 0f;

        // Get Sprite Container
        m_spriteContainerGoldCoin = GameObject.Find ("GoldCoin_Altas_01").GetComponent<OTSpriteAtlasCocos2D>();

        // Init elapsed time
        m_fElapsedTime = 0f;

        // Init State
        m_state = STATE.DISP_NONE;
    }
Example #50
0
 // Use this for initialization
 void Start()
 {
     mySprite = GetComponent<OTAnimatingSprite>();
     jelly = player.GetComponent<Player>();
     movement = GameObject.Find ("powerMeter").GetComponent<Movement>();
 }
Example #51
0
    float starTime = 0; // star creation wait time

    #endregion Fields

    #region Methods

    // Create all objects fo    r the star stage by code
    void AnimatingGreenStarStage()
    {
        // To create a scrolling background, first create a filled sprite object
        back = OT.CreateObject(OTObjectType.FilledSprite).GetComponent<OTFilledSprite>();
        // Set the image to the tile texture
        back.image = whiteTile;
        // Set material reference to 'custom' blue material
        back.materialReference = "blue";
        // Set size to match the screen resolution so it will fill the entire screen
        back.size = new Vector2(Screen.width,Screen.height);
        // Set the display depth all the way back so everything else will come on top
        back.depth = 1000;
        // Set fill image size to 50 x 50 pixels
        back.fillSize = new Vector2(50, 50);
        // Set scroll speed so we will scroll horizontally 20 px / second
        back.scrollSpeed = new Vector2(20, 0);

        // To create the animating star we first have to create the sprite sheet object that will
        // hold our texture/animation frames
        OTSpriteSheet sheet = OT.CreateObject(OTObjectType.SpriteSheet).GetComponent<OTSpriteSheet>();
        // Assign texture
        sheet.texture = greenStarsAnimation;
        // Specify how many columns and rows we have (frames)
        sheet.framesXY = new Vector2(25, 3);
        // Because we have some overhead space to the right and bottom of our texture we have to
        // specify the original texture size and the original frame size so that the right texture
        // scale and offsetting can be calculated.
        sheet.sheetSize = new Vector2(2048, 256);
        sheet.frameSize = new Vector2(80, 80);

        // Next thing is to create the animation that our animating sprite will use
        OTAnimation animation = OT.CreateObject(OTObjectType.Animation).GetComponent<OTAnimation>();
        // This animation will use only one frameset with all animating star frames.
        OTAnimationFrameset frameset = new OTAnimationFrameset();
        // Link up the sprite sheet to this animation's frameset
        frameset.container = sheet;
        // Frameset animation will start at frame index 0
        frameset.startFrame = 0;
        // Frameset animation will end at frame index 69
        frameset.endFrame = 69;
        // Assign this frameset to the animation.
        // HINT : by asigning more than one frameset it is possible to create an animation that will span
        // across mutiple framesets
        // HINT : Because it is possible (and very easy) to play a specific frameset of an animation
        // One could pack a lot of animations into one animation object.
        animation.framesets = new OTAnimationFrameset[] { frameset };
        // Set the duration of this animation
        // HINT : By using the OTAnimationSprite.speed setting one can speed up or slow down a
        // running animation without changing the OTAnimation.fps or .duration setting.
        animation.duration = .95f;
        // Lets give our animation a name
        animation.name = "star-animation";

        // To finally get the animatiing star on screen we will create our animation sprite object
        star = OT.CreateObject(OTObjectType.AnimatingSprite).GetComponent<OTAnimatingSprite>();
        // Link up the animation
        star.animation = animation;
        // Lets start at a random frame
        star.startAtRandomFrame = true;
        // Lets auto-start this animation
        star.playOnStart = true;

        // INFO : This animation 'star' will be center (0,0) positioned and act as a prototype
        // to create more moveing and animating (additive) 'stars'.
    }
Example #52
0
 // Use this for initialization
 void Start()
 {
     mySprite = GetComponent<OTAnimatingSprite>();
     shark = this.gameObject.GetComponent<Shark>();
 }
    // Use this for initialization
    void Start()
    {
        attackAnimation = OT.ObjectByName("PlayerAttackAnimSprite") as OTAnimatingSprite;
        attackAnimation.onAnimationFinish = OnAnimationFinish;
        attackAnimation.onAnimationStart = OnAnimationStart;
        attackAnimation.visible = false;
        liftAnimation = OT.ObjectByName("PlayerAttackLiftAnimSprite") as OTAnimatingSprite;
        liftAnimation.onAnimationFinish = OnAnimationFinish;
        liftAnimation.onAnimationStart = OnAnimationStart;
        liftAnimation.visible = false;
        runAnimation = OT.ObjectByName("PlayerRunAnimSprite") as OTAnimatingSprite;
        runAnimation.visible = false;
        idleAnimation = OT.ObjectByName("PlayerIdleAnimSprite") as OTAnimatingSprite;
        idleAnimation.visible = true;
        jumpAnimation = OT.ObjectByName("PlayerJumpAnimSprite") as OTAnimatingSprite;
        jumpAnimation.visible = false;
        //jumpAnimation.onAnimationFinish = OnAnimationFinish;
        landAnimation = OT.ObjectByName("PlayerLandAnimSprite") as OTAnimatingSprite;
        landAnimation.visible = false;

        AttackBox.SetActive(false);
        attackStartTime = 0f;
        attackLength = 1f;
        comboEndTime = Time.time;
        comboEndLength = 1f;
        //currentCombo = 0;
        currentCombo = ComboManager.CurrentCombo;

        controller = this.gameObject.GetComponent<CharacterController>();
    }
 // Use this for initialization
 void Start()
 {
     sprite = GetComponent <OTAnimatingSprite>();
 }