Exemplo n.º 1
0
 // OnCollision delegate is called when star collides with another 'collidable' object
 // HINT - OnEnter and OnCollision delegates are called exactly at the same time, the only
 // difference is their naming convention
 
 public void OnCollision(OTObject owner)
 {
     // check if we collided with a top block and adjust our speed and rotation accordingly
     if (owner.collisionObject.name.IndexOf("top") == 0 && speed.y > 0)
     {
         speed = new Vector2(speed.x, speed.y * -1);
         if ((speed.x < 0 && rotation > 0) || (speed.x > 0 && rotation < 0))
             rotation *= -1;
     }
     else
         // check if we collided with a bottom block and adjust our speed and rotation accordingly
         if (owner.collisionObject.name.IndexOf("bottom") == 0 && speed.y < 0)
         {
             speed = new Vector2(speed.x, speed.y * -1);
             if ((speed.x < 0 && rotation < 0) || (speed.x > 0 && rotation > 0))
                 rotation *= -1;
         }
         else
             // check if we collided with a left block and adjust our speed and rotation accordingly
             if (owner.collisionObject.name.IndexOf("left") == 0 && speed.x < 0)
             {
                 speed = new Vector2(speed.x * -1, speed.y);
                 if ((speed.y < 0 && rotation > 0) || (speed.y > 0 && rotation < 0))
                     rotation *= -1;
             }
             else
                 // check if we collided with a right block and adjust our speed and rotation accordingly
                 if (owner.collisionObject.name.IndexOf("right") == 0 && speed.x > 0)
                 {
                     speed = new Vector2(speed.x * -1, speed.y);
                     if ((speed.y < 0 && rotation < 0) || (speed.y > 0 && rotation > 0))
                         rotation *= -1;
                 }
 }
Exemplo n.º 2
0
 void SizerDrag(OTObject owner)
 {
     Vector2 s = sizer.position - window.position;
     window.size = new Vector2(s.x-12,(-s.y)+10);
     (window as OTScale9Sprite).Rebuild();
     text.wordWrap = (int)(window.size.x/text.size.x)-100;
 }
Exemplo n.º 3
0
    public void SetParameters(OTObject shooter, Vector2 velocity, float range, 
		float damage, OTObject target, List<Effect> effects)
    {
        _target = target;
        _effects = effects;
        SetParameters(shooter, velocity, range, damage);
    }
Exemplo n.º 4
0
    public void OnCollision(OTObject owner)
    {
        if(areaOfEffect > 0 && (owner.gameObject.layer != gameObject.layer)) {

            Collider[] allUnitsCollided = null;
            if(gameObject.layer == 8) {
                allUnitsCollided = Physics.OverlapSphere(myTransform.position, areaOfEffect, 1 << 9);
            }
            if(gameObject.layer == 9) {
                allUnitsCollided = Physics.OverlapSphere(myTransform.position, areaOfEffect, 1 << 8);
            }
            if(allUnitsCollided != null) {
                foreach(Collider c in allUnitsCollided) {
                    Unit u = c.gameObject.GetComponent<Unit>();
                    if(u) u.dealDamage(damage);
                    //c.gameObject.GetComponent<Unit>().dealDamage(damage);
                }
            }
            if(gameObject != null) DestroyObject(gameObject);
        } else {
            Unit collisionTarget = owner.collisionObject.gameObject.GetComponent<Unit>();

            if(collisionTarget != null) {
                if((gameObject.layer == 8 && collisionTarget.getLayer() == 9) || (gameObject.layer == 9 && collisionTarget.getLayer() == 8)) {
                    //collisionTarget.HP -= damage;
                    collisionTarget.dealDamage(damage);
                    if(gameObject != null)
                        DestroyObject(gameObject);
                        //OT.DestroyObject(gameObject);
                }
            }
        }
    }
Exemplo n.º 5
0
    void DragEnd(OTObject owner)
    {
        GameObject.Find("DragEnd").renderer.enabled = true;

        if (main.onlyOnPurple)
        {
            if (owner.dropTarget==null || owner.dropTarget.name!="draggable sprite purple")
            {
                // invalidate this drop by setting target to null
                owner.dropTarget = null;
                return;
            }
        }

        if (owner.dropTarget!=null)
        {
            GameObject.Find("DragEnd").GetComponent<TextMesh>().text =
                "Drag Ended - dropped on "+owner.dropTarget.name;
        }
        else
            GameObject.Find("DragEnd").GetComponent<TextMesh>().text =
                "Drag Ended";

        OTDebug.Message(GameObject.Find("DragEnd").GetComponent<TextMesh>().text);

        ended = true;
    }
Exemplo n.º 6
0
    void Start()
    {
        _customSize    = customSize;
        _position_     = _position;
        _rotation_     = _rotation;
        _currentScreen = new Vector2(Screen.width, Screen.height);
        _zoom_         = _zoom;
        if (customSize != 0)
        {
            sizeFact = (customSize / pixelPerfectResolution.y) * 2f;
            if (Application.isPlaying && alwaysPixelPerfect)
            {
                customSize *= Screen.height / pixelPerfectResolution.y;
                _customSize = customSize;
            }
        }
        else
        {
            sizeFact = 1;
        }

        if (movementTarget != null)
        {
            movementObject = movementTarget.GetComponent <OTObject>();
        }

        GetWorldRect();
        recordPrefab = true;
    }
Exemplo n.º 7
0
    void OnCollision(OTObject owner)
    {
        //Cambia la direccion de la velocidad segun en que borde rebota la bola.

        if (owner.collisionObject.name.IndexOf("TopBorder") == 0 && speed.y>0){
            speed.y*=-1;
            if ((speed.x < 0 && rotationSpeed > 0) || (speed.x > 0 && rotationSpeed < 0))
                rotationSpeed *= -1;
        }
        else
            if (owner.collisionObject.name.IndexOf("BottomBorder") == 0 && speed.y < 0)
            {
                speed.y *= -1;
                if ((speed.x < 0 && rotationSpeed < 0) || (speed.x > 0 && rotationSpeed > 0))
                    rotationSpeed *= -1;
            }
            else
                if (owner.collisionObject.name.IndexOf("LeftBorder") == 0 && speed.x < 0)
                {
                    speed.x *= -1;
                    if ((speed.y < 0 && rotationSpeed > 0) || (speed.y > 0 && rotationSpeed < 0))
                        rotationSpeed *= -1;
                }
                else
                    if (owner.collisionObject.name.IndexOf("RightBorder") == 0 && speed.x > 0)
                    {
                        speed.x *= -1;
                        if ((speed.y < 0 && rotationSpeed < 0) || (speed.y > 0 && rotationSpeed > 0))
                            rotationSpeed *= -1;
                    }
    }
Exemplo n.º 8
0
	void Dragging(OTObject owner)
	{
		GameObject.Find("Dragging").renderer.enabled = true;		
		GameObject.Find("Dragging").GetComponent<TextMesh>().text = 
			"Dragging at touch position "+((OT.mobile?""+sprite.dragTouch.position:""+Input.mousePosition));
						
	}
Exemplo n.º 9
0
    private void HandleHit(OTObject owner)
    {
        //Get a hold of this enemy ship's data and adjust it
        EnemyShip enemy = owner.collisionObject.GetComponent<EnemyShip>();

        //Handle harvest missiles
        if (isHarvester)
        {
            //TODO: Add consideration for armor
            if (enemy.health <= damage) //it's going to be a killing blow
                gameState.playerScore += (int)(enemy.resourceReward*harvestPercentage);
            enemy.health -= damage;
            //Remove this projectile
            OT.DestroyObject(sprite);
        }
        //Handle smart missiles
        else if (isSmart)
        {
            //Check to see if the enemy is our target
            if (owner.collisionObject.Equals(target))
            {
                enemy.health -= damage;
                //Remove this projectile
                OT.DestroyObject(sprite);
            }
            //not our target? Ignore collision
        }
        else //normal missile, just deal damage and remove the sprite
        {
            enemy.health -= damage;
            //Remove this projectile
            OT.DestroyObject(sprite);
        }
    }
Exemplo n.º 10
0
 // This method will be called when this block is hit.
 /// <exclude />
 public void OnCollision(OTObject owner)
 {
     // Set color fading indicator
     colorFade = true;
     // Reset fade time
     fadeTime = 0;
 }
Exemplo n.º 11
0
	void Dragging(OTObject owner)
	{
		GameObject.Find("Dragging").GetComponent<Renderer>().enabled = true;		
		GameObject.Find("Dragging").GetComponent<TextMesh>().text = 
			"Dragging "+owner.name+" at "+((OT.mobile?""+sprite.dragTouch.position:""+Input.mousePosition))+" -- "+OTDragObject.dragObjects.Count;
						
	}
Exemplo n.º 12
0
 void OnMouseEnterButton(OTObject view)
 {
     if (_buttonState < _mouseOverTexture.Length && _mouseOverTexture[_buttonState] != null)
     {
         _currentButton._image = _mouseOverTexture[_buttonState];
     }
 }
Exemplo n.º 13
0
 void OnMouseExitButton(OTObject view)
 {
     if (_buttonState < _defaultTexture.Length && _defaultTexture[_buttonState] != null)
     {
         _currentButton._image = _defaultTexture[_buttonState];
     }
 }
Exemplo n.º 14
0
 // This method will be called when this block is hit.
 
 public void OnCollision(OTObject owner)
 {
     // Set color fading indicator
     colorFade = true;
     // Reset fade time
     fadeTime = 0;
 }
Exemplo n.º 15
0
    void DragEnd(OTObject owner)
    {
        GameObject.Find("DragEnd").GetComponent <Renderer>().enabled = true;

        if (main.onlyOnPurple)
        {
            if (owner.dropTarget == null || owner.dropTarget.name != "draggable sprite purple")
            {
                // invalidate this drop by setting target to null
                owner.dropTarget = null;
                return;
            }
        }

        if (owner.dropTarget != null)
        {
            GameObject.Find("DragEnd").GetComponent <TextMesh>().text =
                "Drag Ended - dropped on " + owner.dropTarget.name;
        }
        else
        {
            GameObject.Find("DragEnd").GetComponent <TextMesh>().text =
                "Drag Ended";
        }

        OTDebug.Message(GameObject.Find("DragEnd").GetComponent <TextMesh>().text);

        ended = true;
    }
Exemplo n.º 16
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);
    }
Exemplo n.º 17
0
    public void OnCollided(OTObject owner)
    {
        OTObject obj = owner.collisionObject;
        if(Chick_die == false && (obj.name == "Boat0" || obj.name == "Boat1"))
        {
            // make sure the animal is ON the boat
            if((chick.position.x-chick.size.x/2)< (obj.position.x-obj.size.x/2))
                chick.position = new Vector2(obj.position.x-obj.size.x/2+ chick.size.x/2,chick.position.y);
            else if((chick.position.x+chick.size.x/2)> (obj.position.x+obj.size.x/2))//-0.25*obj.size.x is a tolerance
                chick.position = new Vector2(obj.position.x+obj.size.x/2- chick.size.x/2-0.25f*obj.size.x,chick.position.y);

            landBoat = owner.collisionObject;
            landBoatPosX = landBoat.position.x;
            chick.frameIndex = 0;
            chick.rigidbody.velocity = new Vector3(0, 0, 0);
            chick.collidable = false; // no need enter OnCollided any more

            Main.animalSaved++;
            Main.decreaseAnimal(0);

        } else if(Chick_die == false && landBoat == null
                && (obj.name.StartsWith("BackGround_Bottom")  ||  obj.name.StartsWith("Bee_left")
            ||obj.name.StartsWith("Bee_right") ||obj.name.StartsWith("Maneater_plant")))
        {
            died.Play();
            deadTime = Time.time;
            // show the chick dead left object
            chick.frameIndex = 2;
            // set the die flag
            Chick_die = true;
            chick.collidable = false; // no need enter OnCollided any more
        }
    }
Exemplo n.º 18
0
    bool initialized = false; // initialization notifier

    #endregion Fields

    #region Methods

    // 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);
    }
Exemplo n.º 19
0
    private void HandleHit(OTObject owner)
    {
        //Get a hold of this enemy ship's data and adjust it
        EnemyShip enemy = owner.collisionObject.GetComponent<EnemyShip>();
        enemy.health -= damage;
        //Handle flak projectiles
        if (isFlak)
        {
            //make an explosion of slugs generate 5 slugs that fly in random directions... OLD BEHAVIOUR
            /*
            for (int i = 0; i < 5; i++)
            {
                GameObject bullet = OT.CreateObject("PlayerCannonProjectile");
                myProjectile = bullet.GetComponent<OTSprite>();
                myProjectile.renderer.enabled = true;

                // fire in a random direction
                Vector2 target = new Vector2(Random.value*100-50,Random.value*100-50);
                myProjectile.position = sprite.position;
                myProjectile.RotateTowards(target);

                //Assign the projectile its atributes.
                PlayerCannonProjectile pcp = (PlayerCannonProjectile)myProjectile.GetComponent(typeof(PlayerCannonProjectile));
                pcp.damage = damage;
                pcp.speed = speed;
                pcp.isFlak = false;
            }
            */
            //Now we do nothing special here
        }
        //Handle super flaks
        if (isSuperFlak)
        {
            /*
            //make an explosion of slugs generate 5 slugs that fly in random directions
            for (int i = 0; i < 5; i++)
            {
                GameObject bullet = OT.CreateObject("PlayerCannonProjectile");
                myProjectile = bullet.GetComponent<OTSprite>();
                myProjectile.renderer.enabled = true;

                // fire in a random direction
                Vector2 target = new Vector2(Random.value*100-50,Random.value*100-50);
                myProjectile.position = sprite.position;
                myProjectile.RotateTowards(target);

                //Assign the projectile its atributes.
                PlayerCannonProjectile pcp = (PlayerCannonProjectile)myProjectile.GetComponent(typeof(PlayerCannonProjectile));
                pcp.damage = damage;
                pcp.speed = speed;
                pcp.isFlak = true;
                pcp.isSuperFlak = false;
            }
            */
            // Now we do nothing special here
        }
        //Remove this projectile
        OT.DestroyObject(sprite);
    }
 // 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;
     }
 }
Exemplo n.º 21
0
    void SizerDrag(OTObject owner)
    {
        Vector2 s = sizer.position - window.position;

        window.size = new Vector2(s.x - 12, (-s.y) + 10);
        (window as OTScale9Sprite).Rebuild();
        text.wordWrap = (int)(window.size.x / text.size.x) - 100;
    }
Exemplo n.º 22
0
 public void OnCollision(OTObject owner)
 {
     //Check to see if the collision is with an enemy ship
     if (owner.collisionObject.name.ToLower().Contains("enemyship"))
     {
         HandleHit(owner);
     }
 }
Exemplo n.º 23
0
 public void OnEnterCollision(OTObject target)
 {
     if (target.tag.Contains("enemy"))
     {
         dealDamages(target.tag);
         gameScript.destroyEnemy(target.gameObject.GetComponent <OTSprite>(), true);
     }
 }
 // Orthello Input handler
 public void OnInput(OTObject owner)
 {
     // check if we clicked the left mouse button
     if (Input.GetMouseButtonDown(0))
     {
         script.SendMessage("Clicked", this);
     }
 }
Exemplo n.º 25
0
 // OnExit delegate is called when star no longer overlaps another 'collidable' object
 /// <exclude />
 public void OnExit(OTObject owner)
 {
     // check if we have left another star and adjust color if we did
     if (owner.collisionObject.name.IndexOf("star") == 0)
     {
         sprite.material = OT.LookupMaterial("Star-start");
     }
 }
 public void OnAnimationFinished(OTObject owner)
 {
     if (MySprite.animationFrameset == "ai") {
         MySprite.looping = true;
         MySprite.animationFrameset = "run";
         Debug.Log ("1");
         MySprite.Play ();
     }
 }
Exemplo n.º 27
0
    private void OnGameLaunch(OTObject view)
    {
        bool inputFlag = Constants.GetInputDown();

        if (inputFlag)
        {
            LaunchGame();
        }
    }
Exemplo n.º 28
0
    public void SetParemeters(OTObject shooter, float damage)
    {
        _AOE = GetComponent<OTAnimatingSprite>();
        _AOE.onCollision = OnCollision;
        _shooter = shooter;
        _damage = damage;

        _AOE.transform.parent = AOEContainer.transform;
    }
Exemplo n.º 29
0
    // The OnAnimationFinish delegate will be called when an animation or animation frameset
    // finishes playing.

    public void OnAnimationFinish(OTObject owner)
    {
        if (owner == gun)
        {
            // Because the only animation that finishes will be the gun's 'shoot' animation frameset
            // we know that we have to switch to the gun's looping 'idle' animation frameset
            gun.PlayLoop("idle");
        }
    }
Exemplo n.º 30
0
 private void HandleHitWorld(OTObject owner)
 {
     //Get a hold of the city data and adjust it
     //TODO implement damage reduction appropriately
     World world = owner.collisionObject.GetComponent<World>();
     world.health -= damage;
     //Remove this projectile
     OT.DestroyObject(sprite);
 }
Exemplo n.º 31
0
 // The OnAnimationFinish delegate will be called when an animation or animation frameset
 // finishes playing.
 public void OnAnimationFinish(OTObject owner)
 {
     if (owner == gun)
     {
         // Because the only animation that finishes will be the gun's 'shoot' animation frameset
         // we know that we have to switch to the gun's looping 'idle' animation frameset
         gun.PlayLoop("idle");
     }
 }
    // rotate a physical static object
    void Rotate(string name)
    {
        OTObject o = OT.ObjectByName(name);

        if (o != null)
        {
            o.rotation += (90 * Time.deltaTime);
        }
    }
Exemplo n.º 33
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);
        OTSprite sprite = null;

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

        case 2: sprite = OT.CreateSprite("asteroid2");
            break;

        case 3: sprite = OT.CreateSprite("asteroid3");
            break;
        }
        // big blocks start invisible and will be faded.
        if (o == null)
        {
            sprite.alpha = 0;
        }
        if (sprite != null)
        {
            // Set sprite's size
            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;
            }
        }

        // fade in the (big) asteroid
        if (o == null)
        {
            new OTTween(sprite, 0.75f, OTEasing.Linear).Wait(Random.value * 1).Tween("alpha", 0, 1);
        }

        return(sprite as OTAnimatingSprite);
    }
Exemplo n.º 34
0
    void DragStart(OTObject owner)
    {
        GameObject.Find("DragStart").renderer.enabled = true;
        GameObject.Find("Dragging").renderer.enabled  = false;
        GameObject.Find("DragEnd").renderer.enabled   = false;
        ended    = false;
        endTimer = 0;

        OTDebug.Message("start dragging " + owner.name);
    }
Exemplo n.º 35
0
    void DragStart(OTObject owner)
    {
        GameObject.Find("DragStart").renderer.enabled = true;
        GameObject.Find("Dragging").renderer.enabled = false;
        GameObject.Find("DragEnd").renderer.enabled = false;
        ended = false;
        endTimer = 0;

        OTDebug.Message("start dragging "+owner.name);
    }
Exemplo n.º 36
0
 public void OnAnimationFinished(OTObject owner)
 {
     if (MySprite.animationFrameset == "ai")
     {
         MySprite.looping           = true;
         MySprite.animationFrameset = "run";
         Debug.Log("1");
         MySprite.Play();
     }
 }
Exemplo n.º 37
0
 public void OnCollision(OTObject owner)
 {
     //Check to see if the collision is with an enemy ship
     if (owner.collisionObject.name.Equals("City"))
         HandleHitCity(owner);
     if (owner.collisionObject.name.Contains("World"))
         HandleHitWorld(owner);
     if (owner.collisionObject.name.Equals("CityShield"))
         HandleHitCityShield(owner);
 }
Exemplo n.º 38
0
    void OnPageChangeButton(OTObject view)
    {
        bool flag = Constants.GetInputDown();

        if (flag && !isCameraMoving)
        {
            int pageChange = (cameraGroup.transform.position.y > 0) ? -1 : 1;
            PageFlip(pageChange, true);
        }
    }
Exemplo n.º 39
0
 public static void OnBlockInput(OTObject owner)
 {
     // check for the left mouse button
     if (Input.GetMouseButtonDown(0))
     {
         MapBlockData data = GetBlockData(owner);
         //GameControl.Instance.DebugLog(" data : " + data.Row.ToString() + "   " + data.Column.ToString());
         GameControl.Instance.MapTileClick(data);
     }
 }
Exemplo n.º 40
0
    // Set scroll speed for a specific FilledSprite providing its name
    void SetScroll(string spriteName, Vector2 scrollSpeed)
    {
        // lookup sprite
        OTObject sprite = OT.ObjectByName(spriteName);

        // set scroll speed
        if (sprite != null)
        {
            (sprite as OTFilledSprite).scrollSpeed = scrollSpeed;
        }
    }
Exemplo n.º 41
0
    void DragStart(OTObject owner)
    {
        GameObject.Find("DragStart").renderer.enabled = true;
        GameObject.Find("Dragging").renderer.enabled = false;
        GameObject.Find("DragEnd").renderer.enabled = false;
        ended = false;
        endTimer = 0;

        GameObject.Find("DragStart").GetComponent<TextMesh>().text = "start dragging "+owner.name;
        OTDebug.Message("start dragging "+owner.name);
    }
Exemplo n.º 42
0
    void DragStart(OTObject owner)
    {
        GameObject.Find("DragStart").GetComponent <Renderer>().enabled = true;
        GameObject.Find("Dragging").GetComponent <Renderer>().enabled  = false;
        GameObject.Find("DragEnd").GetComponent <Renderer>().enabled   = false;
        ended    = false;
        endTimer = 0;

        GameObject.Find("DragStart").GetComponent <TextMesh>().text = "start dragging " + owner.name;
        OTDebug.Message("start dragging " + owner.name);
    }
Exemplo n.º 43
0
    public override void Assign(OTObject protoType)
    {
        base.Assign(protoType);
        OTSprite pSprite = protoType as OTSprite;

        tintColor         = pSprite.tintColor;
        alpha             = pSprite.alpha;
        image             = pSprite.image;
        spriteContainer   = pSprite.spriteContainer;
        frameIndex        = pSprite.frameIndex;
        materialReference = pSprite.materialReference;
    }
Exemplo n.º 44
0
 // OnCollision delegate is called when this bullet collides with another 'collidable' object
 // !IMPORTANT - This sprite's collidable setting has to be true otherwide
 // collision delegates will not be called
 /// <exclude />
 public void OnCollision(OTObject owner)
 {
     // check if the asteroid we are colliding with is not in our
     // ignore debree list.
     if (debree.IndexOf(owner.collisionObject as OTAnimatingSprite) < 0)
     {
         // We have to ignore debree the following 0.1 seconds
         ignoreCollisions = 0.1f;
         // Lets Explode this asteroid
         app.Explode(owner.collisionObject, this);
     }
 }
Exemplo n.º 45
0
    bool scrolling   = false;           // scrolling notifier

    // This method will resize the a FilledSprite ( provided by name )
    // to match the current view (resolution).
    void Resize(string spriteName)
    {
        // Lookup the FilledSprite using its name.
        OTObject sprite = OT.ObjectByName(spriteName);

        if (sprite != null)
        {
            // We found the sprite so lets size it to match the screen's resolution
            // We will assume the OTView.zoom factor is set to zero (no zooming)
            sprite.size = new Vector2(Screen.width, Screen.height);
        }
    }
Exemplo n.º 46
0
    // Input handler

    public void OnInput(OTObject owner)
    {
        // check if we clicked the left mouse button
        if (Input.GetMouseButtonDown(0))
        {
            // Link View target object for movement and rotation
            OT.view.movementTarget = owner.gameObject;
            OT.view.rotationTarget = owner.gameObject;
            // We want to zoom in on that target
            zooming = true;
        }
    }
Exemplo n.º 47
0
    // OnCollision delegate is called when this bullet collides with another 'collidable' object
    // !IMPORTANT - This sprite's collidable setting has to be true otherwide
    // collision delegates will not be called

    public void OnCollision(OTObject owner)
    {
        // check if the asteroid we are colliding with is not in our
        // ignore debree list.
        if (debree.IndexOf(owner.collisionObject as OTAnimatingSprite) < 0)
        {
            // We have to ignore debree the following 0.1 seconds
            ignoreCollisions = 0.1f;
            // Lets Explode this asteroid
            app.Explode(owner.collisionObject, this);
        }
    }
Exemplo n.º 48
0
    float zoomSpeed = 4f; // how fast do we zoom in/out

    #endregion Fields

    #region Methods

    // Input handler
    public void OnInput(OTObject owner)
    {
        // check if we clicked the left mouse button
        if (Input.GetMouseButtonDown(0))
        {
            // Link View target object for movement and rotation
            OT.view.movementTarget = owner.gameObject;
            OT.view.rotationTarget = owner.gameObject;
            // We want to zoom in on that target
            zooming = true;
        }
    }
Exemplo n.º 49
0
    void ReceiveDrop(OTObject owner)
    {
        if (main.lockPurple && sprite.name == "draggable sprite purple")
        {
            // invalidate this drop by setting target to null
            owner.dropTarget = null;
            return;
        }

        GameObject.Find("Dragging").GetComponent <TextMesh>().text =
            owner.name + " received drop from " + owner.dropTarget.name;
        OTDebug.Message(GameObject.Find("Dragging").GetComponent <TextMesh>().text);
    }
Exemplo n.º 50
0
    void ReceiveDrop(OTObject owner)
    {
        if (main.lockPurple && sprite.name=="draggable sprite purple")
        {
            // invalidate this drop by setting target to null
            owner.dropTarget = null;
            return;
        }

        GameObject.Find("Dragging").GetComponent<TextMesh>().text =
            owner.name+" received drop from "+owner.dropTarget.name;
        OTDebug.Message(GameObject.Find("Dragging").GetComponent<TextMesh>().text);
    }
Exemplo n.º 51
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);
    }
Exemplo n.º 52
0
 void TilesInput(OTObject owner)
 {
     if (Input.GetMouseButtonDown(0))
     {
         // clicked on the sheet;
         IVector2 tile = ts.hitTile;
         TileInfo tileInfo = (ts.objects[tile.x][tile.y] as TileInfo);
         if (tile!=null)
         {
             txt.text	= "clicked tile "+tile+"\n"+
                           tileInfo.description;
         }
     }
 }
Exemplo n.º 53
0
	void DragEnd(OTObject owner)
	{
		GameObject.Find("DragEnd").renderer.enabled = true;		
		if (owner.dropTarget!=null)
			GameObject.Find("DragEnd").GetComponent<TextMesh>().text = 
				"Drag Ended - dropped on "+owner.dropTarget.name;
		else
			GameObject.Find("DragEnd").GetComponent<TextMesh>().text = 
				"Drag Ended";

		OTDebug.Message(GameObject.Find("DragEnd").GetComponent<TextMesh>().text);
		
		ended = true;
	}
Exemplo n.º 54
0
 void onEnterCollision(OTObject owner)
 {
     if (owner.tag.Contains("bullet"))
     {
         if (tag == "enemySupernova")
         {
             gameScript.displayPickup(transform.position, 0);
             gameScript.setBulletType(Game.bulletType.Supernova);
         }
         else if (tag == "enemyFreeze")
         {
             gameScript.setBulletType(Game.bulletType.Freeze);
         }
         else if (tag == "enemyShield")
         {
             gameScript.augmentShield();
         }
         else if (tag == "enemyFuel")
         {
             gameScript.augmentFuel();
         }
         else if (tag == "enemyBomb")
         {
             gameScript.incBombCount();
         }
         if (owner.tag == "bulletSupernova")
         {
             // TODO supernova animation
             // TODO supernova sound
             Collider[] objs = Physics.OverlapSphere(transform.position, supernovaSize);
             foreach (Collider obj in objs)
             {
                 if (obj.tag != "player" && obj != this)
                 {
                     gameScript.destroyEnemy(obj.gameObject.GetComponent <OTSprite>(), true);
                 }
             }
             // TODO remove bullet • see ricochet
         }
         else if (owner.tag == "bulletFreeze")
         {
             // TODO freeze animation
             // TODO freeze sound
             gravityWeight = 0;
             speed         = 0;
             // TODO remove bullet • see ricochet
         }
         gameScript.destroyEnemy(gameObject.GetComponent <OTSprite>(), false);
     }
 }
Exemplo n.º 55
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);
        OTSprite sprite = null;
        // Create a new asteroid
        switch (t)
        {
            case 1:
                sprite = OT.CreateSprite("Monsters");
                sprite.frameIndex = 1;
                break;
            case 2:
                sprite = OT.CreateSprite("Monsters");
                sprite.frameIndex = 2;
                break;
            case 3:
                sprite = OT.CreateSprite("Monsters");
                sprite.frameIndex = 3;
                break;
        }
        // big blocks start invisible and will be faded.
        if (o == null)
            sprite.alpha = 0;
        if (sprite != null)
        {
            // Set sprite's size
            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;
            sprite.depth = -10;
        }

        // fade in the (big) asteroid
        if (o == null)
            new OTTween(sprite,0.75f,OTEasing.Linear).Wait(Random.value * 1).Tween("alpha",0,1);

        return sprite as OTAnimatingSprite;
    }
Exemplo n.º 56
0
    public void SetParameters(OTObject shooter, Vector2 velocity, float range, float damage)
    {
        if (arrow == null)
        {
            arrow = GetComponent<OTSprite>();
            arrow.onCollision = OnCollision;
        }
        _shooter = shooter;
        arrow.position = _shooter.position;
        _velocity = velocity;
        _range = range;
        _damage = damage;

        arrow.transform.parent = ArrowContainer.transform;
    }
Exemplo n.º 57
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;
	}
Exemplo n.º 58
0
    public static MapBlockData GetBlockData(OTObject sprite)
    {
        if (sprite == null)
        {
            GameControl.Instance.DebugLog("sprite == null");
            return(null);
        }

        if (sprite.gameObject == null)
        {
            GameControl.Instance.DebugLog("sprite.gameObject == null");
            return(null);
        }

        return(sprite.gameObject.GetComponentInChildren <MapBlockData>());
    }
Exemplo n.º 59
0
    private void OnCollision(OTObject owner)
    {
        // already administer damage; return
        if(_played)
        {
            return;
        }

        OTObject target = owner.collisionObject;

        if(target is OTSprite &&
            target.baseName == "monster")
        {
            _playing = true;
            target.GetComponent<MonsterStatManager>().RegisterDamage(_damage);
        }
    }
Exemplo n.º 60
0
    private void HandleHit(OTObject owner)
    {
        //Get a hold of this enemy ship's data and adjust it
        EnemyShip enemy = owner.collisionObject.GetComponent<EnemyShip>();
        enemy.health -= damage;

        //If this beam is a stun beam then stun the enemyship
        if (isStun)
        {
            enemy.stunned = true;
            enemy.stunnedTime = 0.0f;
            enemy.stunDuration = stunDuration;
        }

        //Remove this projectile if it is not a laser
        if (!(isLaser))
            HandleFizzle();
    }