BuildUVAnim() public method

public BuildUVAnim ( Vector2 start, Vector2 cellSize, int cols, int rows, int totalCells, float fps ) : Vector2[]
start Vector2
cellSize Vector2
cols int
rows int
totalCells int
fps float
return Vector2[]
    // Use this for initialization
    void Start()
    {
        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 511, 512, 512, false);

        // Create and setup anims
        UVAnimation anim       = new UVAnimation();
        var         firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 511));
        var         cellSize   = spriteManager.PixelSpaceToUVSpace(new Vector2(512, 512));

        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 16, 15);
        anim.name       = "Idle";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);

        anim       = new UVAnimation();
        firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 1535));
        cellSize   = spriteManager.PixelSpaceToUVSpace(new Vector2(512, 512));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 19, 15);
        anim.name       = "Surprise";
        anim.loopCycles = 0;

        sprite.AddAnimation(anim);

        sprite.PlayAnim("Idle");
    }
Ejemplo n.º 2
0
    // Use this for initialization
    public override void Start()
    {
        base.Start();

        GetComponent <SimpleFollow>().enabled = false;
        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);

        // Create and setup anims
        UVAnimation anim       = new UVAnimation();
        var         firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        var         cellSize   = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));

        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 14, 15);
        anim.name       = "Idle";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);

        anim       = new UVAnimation();
        firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 383));
        cellSize   = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 16, 15);
        anim.name       = "Die";
        anim.loopCycles = 0;

        sprite.AddAnimation(anim);

        sprite.PlayAnim("Idle");
    }
    // Use this for initialization
    void Start()
    {
        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);

        // Create and setup anims
        UVAnimation anim = new UVAnimation();
        var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 13, 15);
        anim.name = "Idle";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);

        anim = new UVAnimation();
        firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 13, 30);
        anim.name = "Arm";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);

        anim = new UVAnimation();
        firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(256, 383));
        cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 8, 30);
        anim.name = "Explode";
        anim.loopCycles = 1;

        sprite.AddAnimation(anim);

        sprite.PlayAnim("Idle");
    }
    // Use this for initialization
    void Start()
    {
        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);

        // Create and setup anims
        UVAnimation anim       = new UVAnimation();
        var         firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        var         cellSize   = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));

        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 13, 15);
        anim.name       = "Idle";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);

        anim       = new UVAnimation();
        firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        cellSize   = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 13, 30);
        anim.name       = "Arm";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);

        anim       = new UVAnimation();
        firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(256, 383));
        cellSize   = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 8, 30);
        anim.name       = "Explode";
        anim.loopCycles = 1;

        sprite.AddAnimation(anim);

        sprite.PlayAnim("Idle");
    }
Ejemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        agent      = gameObject.GetComponent <Seeker>();
        controller = gameObject.GetComponent <CharacterController>();


        spriteManager = gameObject.GetComponent <SpriteManager>() as SpriteManager;

        evilSprite = spriteManager.AddSprite(gameObject, 2.0f, 2.0f, spriteManager.PixelSpaceToUVSpace(256, 256), spriteManager.PixelSpaceToUVSpace(50, 50), false);
        evilSprite.SetAnimCompleteDelegate(OnAnimateComplete);

        Vector2 spriteSize = spriteManager.PixelSpaceToUVSpace(50, 50);

        //Idle animation
        UVAnimation idleAnimation  = new UVAnimation();
        Vector2     idleStartPosUV = spriteManager.PixelCoordToUVCoord(0, 50);

        idleAnimation.BuildUVAnim(idleStartPosUV, spriteSize, 3, 2, 6, 15);
        idleAnimation.loopCycles = -1;
        idleAnimation.name       = "idle";
        evilSprite.AddAnimation(idleAnimation);

        evilSprite.PlayAnim("idle");
        gameObject.transform.position = startPos;
    }
Ejemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        spriteManager = gameObject.GetComponent <SpriteManager>() as SpriteManager;

        weaponSprite = spriteManager.AddSprite(gameObject, 1.0f, 1.0f, spriteManager.PixelSpaceToUVSpace(512, 512), spriteManager.PixelSpaceToUVSpace(72, 78), false);
        weaponSprite.SetAnimCompleteDelegate(OnAnimateComplete);

        Vector2 spriteSize = spriteManager.PixelSpaceToUVSpace(72, 78);

        //Idle animation
        UVAnimation idleAnimation  = new UVAnimation();
        Vector2     idleStartPosUV = spriteManager.PixelCoordToUVCoord(0, 78);

        idleAnimation.BuildUVAnim(idleStartPosUV, spriteSize, 1, 1, 1, 15);
        idleAnimation.loopCycles = -1;
        idleAnimation.name       = "idle";
        weaponSprite.AddAnimation(idleAnimation);

        UVAnimation shootAnimation  = new UVAnimation();
        Vector2     shootStartPosUV = spriteManager.PixelCoordToUVCoord(0, 78);

        shootAnimation.BuildUVAnim(shootStartPosUV, spriteSize, 3, 2, 5, 15);
        shootAnimation.loopCycles = 0;
        shootAnimation.name       = "shoot";
        weaponSprite.AddAnimation(shootAnimation);

        transform.parent = GameObject.Find("Main Camera").transform;

        transform.localPosition = localPos;
        transform.rotation      = GameObject.Find("Main Camera").transform.rotation;
    }
Ejemplo n.º 7
0
    protected override void createAnimations()
    {
        // Set up left animation
        leftAnim            = new UVAnimation();
        leftAnim.name       = "EighthRest Left Animation";
        leftAnim.loopCycles = -1;
        leftAnim.framerate  = 24;

        leftAnim.BuildUVAnim(new Vector2(0f, 12f / numRows), cellSize, 18, 1, 18, 24);
        sprite.AddAnimation(leftAnim);


        // Set up right animation
        rightAnim            = new UVAnimation();
        rightAnim.name       = "EighthRest Right Animation";
        rightAnim.loopCycles = -1;
        rightAnim.framerate  = 24;

        rightAnim.BuildUVAnim(new Vector2(0f, 11f / numRows), cellSize, 18, 1, 18, 24);
        sprite.AddAnimation(rightAnim);

        // Starting direction
        EighthRest er = this.gameObject.GetComponent(typeof(EighthRest)) as EighthRest;

        if (er.isMovingRight)
        {
            sprite.PlayAnim(rightAnim);
        }
        else
        {
            sprite.PlayAnim(leftAnim);
        }
    }
    // Use this for initialization
    void Start()
    {
        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 511, 512, 512, false);

        // Create and setup anims
        UVAnimation anim = new UVAnimation();
        var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 511));
        var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(512, 512));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 16, 15);
        anim.name = "Idle";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);

        anim = new UVAnimation();
        firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 1023));
        cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(512, 512));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 19, 15);
        anim.name = "Surprise";
        anim.loopCycles = 0;

        sprite.AddAnimation(anim);

        sprite.PlayAnim("Idle");
    }
    // Use this for initialization
    public override void Start()
    {
        base.Start();

        GetComponent<SimpleFollow>().enabled = false;
        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);

        // Create and setup anims
        UVAnimation anim = new UVAnimation();
        var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 14, 15);
        anim.name = "Idle";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);

        anim = new UVAnimation();
        firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 383));
        cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 16, 15);
        anim.name = "Die";
        anim.loopCycles = 0;

        sprite.AddAnimation(anim);

        sprite.PlayAnim("Idle");
    }
    public override void Start()
    {
        base.Start();

        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);

        // Create and setup anims
        UVAnimation anim       = new UVAnimation();
        var         firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        var         cellSize   = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));

        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 14, 15);
        anim.name       = "Idle";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);

        anim       = new UVAnimation();
        firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 383));
        cellSize   = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 16, 15);
        anim.name       = "Die";
        anim.loopCycles = 0;

        sprite.AddAnimation(anim);

        sprite.PlayAnim("Idle");

        dolphin = GameObject.Find("DolphinSprite");
        Util.Assert(dolphin != null);
    }
Ejemplo n.º 11
0
 // Use this for initialization
 void Start()
 {
     sprite = spriteManager.AddSprite(this.gameObject,2,2,new Vector2(.5f,.5f), new Vector2(.25f, .5f), new Vector3(0,0,0), true);
     stabbing = new UVAnimation();
     stabbing.name="stabbing";
     stabbing.SetAnim(stabbing.BuildUVAnim(new Vector2(.5f,.5f),new Vector2(.25f,.5f),2,2,3,2));
     stabbing.loopCycles=-1; // makes animation loop infinitely
     stabbing.loopReverse = true; // makes animation go in reverse after it's completed
     sprite.AddAnimation(stabbing);
     sprite.PlayAnim("stabbing");
 }
Ejemplo n.º 12
0
	protected UVAnimation CreateAnimation(string animName, Vector2 startUVPos, Vector2 UVSize, int animCells, int loopCycles, bool pingPongAnim, float framerate){
		UVAnimation anim = new UVAnimation();
		anim.name = animName;
		anim.loopCycles = loopCycles;
		anim.framerate = framerate;
		if(pingPongAnim)
			anim.loopReverse = true;
		
		anim.BuildUVAnim(startUVPos, UVSize, spriteSheetCols, spriteSheetRows, animCells, framerate);		
		return anim;
	}
Ejemplo n.º 13
0
    public override void AddJumpAnimation()
    {
        jumpAnim = new UVAnimation();

        Vector2 startPosUV = sm.PixelCoordToUVCoord(0, 1024);
        Vector2 spriteSize = sm.PixelSpaceToUVSpace(256, 256);

        jumpAnim.BuildUVAnim(startPosUV, spriteSize, 11, 1, 11, animationFps);

        jumpAnim.name = JUMP;

        sprite.AddAnimation(jumpAnim);
    }
Ejemplo n.º 14
0
    public void AddForwardDashAnimation()
    {
        forwardDashAnim = new UVAnimation();

        Vector2 startPosUV = sm.PixelCoordToUVCoord(0, 1536);
        Vector2 spriteSize = sm.PixelSpaceToUVSpace(256, 256);

        forwardDashAnim.BuildUVAnim(startPosUV, spriteSize, 6, 1, 6, 15);

        forwardDashAnim.name = FORWARDDASH;

        sprite.AddAnimation(forwardDashAnim);
    }
Ejemplo n.º 15
0
    public override void AddForwardJumpAnimation()
    {
        forwardJumpAnim = new UVAnimation();

        Vector2 startPosUV = sm.PixelCoordToUVCoord(0, 1280);
        Vector2 spriteSize = sm.PixelSpaceToUVSpace(256, 256);

        forwardJumpAnim.BuildUVAnim(startPosUV, spriteSize, 14, 1, 14, animationFps);

        forwardJumpAnim.name = FORWARDJUMP;

        sprite.AddAnimation(forwardJumpAnim);
    }
Ejemplo n.º 16
0
    public void AddShoryukenAnimation()
    {
        shoryukenAnim = new UVAnimation();

        Vector2 startPosUV = sm.PixelCoordToUVCoord(1024, 1792);
        Vector2 spriteSize = sm.PixelSpaceToUVSpace(256, 256);

        shoryukenAnim.BuildUVAnim(startPosUV, spriteSize, 5, 1, 5, 10);

        shoryukenAnim.name = SHORYUKEN;

        sprite.AddAnimation(shoryukenAnim);
    }
Ejemplo n.º 17
0
    public void AddHadoukenAnimation()
    {
        hadoukenAnim = new UVAnimation();

        Vector2 startPosUV = sm.PixelCoordToUVCoord(0, 2048);
        Vector2 spriteSize = sm.PixelSpaceToUVSpace(256, 256);

        hadoukenAnim.BuildUVAnim(startPosUV, spriteSize, 11, 1, 11, animationFps);

        hadoukenAnim.name = HADOUKEN;

        sprite.AddAnimation(hadoukenAnim);
    }
Ejemplo n.º 18
0
    public void AddNormalHitAnimation()
    {
        normalHitAnim = new UVAnimation();

        Vector2 startPosUV = sm.PixelCoordToUVCoord(2816, 768);
        Vector2 spriteSize = sm.PixelSpaceToUVSpace(256, 256);

        normalHitAnim.BuildUVAnim(startPosUV, spriteSize, 5, 1, 5, animationFps);

        normalHitAnim.name = NORMALHIT;

        sprite.AddAnimation(normalHitAnim);
    }
Ejemplo n.º 19
0
    public void AddBackDashAnimation()
    {
        backDashAnim = new UVAnimation();

        Vector2 startPosUV = sm.PixelCoordToUVCoord(0, 1792);
        Vector2 spriteSize = sm.PixelSpaceToUVSpace(256, 256);

        backDashAnim.BuildUVAnim(startPosUV, spriteSize, 4, 1, 4, animationFps);

        backDashAnim.name = BACKDASH;

        sprite.AddAnimation(backDashAnim);
    }
Ejemplo n.º 20
0
    protected override void createAnimations()
    {
        // Set up animation
        anim            = new UVAnimation();
        anim.name       = "Flat Animation";
        anim.loopCycles = -1;
        anim.framerate  = 24;

        anim.BuildUVAnim(new Vector2(0f, 8f / numRows), cellSize, 18, 1, 18, 24);
        sprite.AddAnimation(anim);

        sprite.PlayAnim(anim);
    }
Ejemplo n.º 21
0
    // Use this for initialization
    void Start()
    {
        sm     = GameObject.Find("_SpriteManager").GetComponent <LinkedSpriteManager>();
        sprite = sm.AddSprite(this.gameObject, 1f, 1f, sm.PixelCoordToUVCoord(0, 9 * 96), sm.PixelSpaceToUVSpace(192, 192), Vector3.zero, false);
        sprite.SetDrawLayer(100);
        UVAnimation anim = new UVAnimation();

        anim.BuildUVAnim(sm.PixelCoordToUVCoord(0, 9 * 96), sm.PixelSpaceToUVSpace(192, 192), 5, 1, 5, 56f);
        anim.loopCycles = 0;
        sprite.AddAnimation(anim);
        sprite.PlayAnim(anim);
        Invoke("destroySelf", .125f);
    }
Ejemplo n.º 22
0
    public void AddAirDashAnimation()
    {
        airDashAnim = new UVAnimation();

        Vector2 startPosUV = sm.PixelCoordToUVCoord(2560, 256);
        Vector2 spriteSize = sm.PixelSpaceToUVSpace(256, 256);

        airDashAnim.BuildUVAnim(startPosUV, spriteSize, 4, 1, 4, animationFps);

        airDashAnim.name = AIRDASH;

        sprite.AddAnimation(airDashAnim);
    }
Ejemplo n.º 23
0
    public override void AddMoveAnimation()
    {
        moveAnimation = new UVAnimation();

        Vector2 startPosUV = sm.PixelCoordToUVCoord(0, 84);
        Vector2 spriteSize = sm.PixelSpaceToUVSpace(88, 84);

        moveAnimation.BuildUVAnim(startPosUV, spriteSize, 8, 2, 8, animationFps);

        moveAnimation.name       = MOVE;
        moveAnimation.loopCycles = -1;

        sprite.AddAnimation(moveAnimation);
    }
Ejemplo n.º 24
0
    public override void AddStandingAnimation()
    {
        standingAnim = new UVAnimation();

        Vector2 startPosUV = sm.PixelCoordToUVCoord(0, 256);
        Vector2 spriteSize = sm.PixelSpaceToUVSpace(256, 256);

        standingAnim.BuildUVAnim(startPosUV, spriteSize, 9, 1, 9, animationFps);

        standingAnim.name       = STANDING;
        standingAnim.loopCycles = -1;

        sprite.AddAnimation(standingAnim);
    }
Ejemplo n.º 25
0
    public override void AddWalkForwardAnimation()
    {
        walkForwardAnim = new UVAnimation();

        Vector2 startPosUV = sm.PixelCoordToUVCoord(256, 512);
        Vector2 spriteSize = sm.PixelSpaceToUVSpace(256, 256);

        walkForwardAnim.BuildUVAnim(startPosUV, spriteSize, 11, 1, 11, animationFps);

        walkForwardAnim.name       = WALKFORWARD;
        walkForwardAnim.loopCycles = -1;

        sprite.AddAnimation(walkForwardAnim);
    }
Ejemplo n.º 26
0
    public override void AddBackpedalAnimation()
    {
        backpedalAnim = new UVAnimation();

        Vector2 startPosUV = sm.PixelCoordToUVCoord(0, 768);
        Vector2 spriteSize = sm.PixelSpaceToUVSpace(256, 256);

        backpedalAnim.BuildUVAnim(startPosUV, spriteSize, 11, 1, 11, animationFps);

        backpedalAnim.name       = BACKPEDAL;
        backpedalAnim.loopCycles = -1;

        sprite.AddAnimation(backpedalAnim);
    }
Ejemplo n.º 27
0
    override public void initialize(Vector3 dir, M_Entity sender)
    {
        Invoke("destroySelf", lifetime);
        entity    = sender;
        direction = dir;

        sm     = GameObject.Find("_SpriteManager").GetComponent <LinkedSpriteManager>();
        sprite = sm.AddSprite(this.gameObject, 1f, 1f, sm.PixelCoordToUVCoord(0, 12 * 96), sm.PixelSpaceToUVSpace(96, 96), Vector3.zero, false);
        sprite.SetDrawLayer(100);

        dieAnim = new UVAnimation();
        dieAnim.BuildUVAnim(sm.PixelCoordToUVCoord(0, 12 * 96), sm.PixelSpaceToUVSpace(96, 96), 4, 1, 4, 16f);
        dieAnim.loopCycles = 0;
        sprite.AddAnimation(dieAnim);
    }
Ejemplo n.º 28
0
    private void createSprite()
    {
        enemySprite = spriteManager.AddSprite(gameObject, InGameSize.x, InGameSize.y, spriteManager.PixelSpaceToUVSpace((int)TextureSize.x, (int)TextureSize.y), spriteManager.PixelSpaceToUVSpace((int)FrameSize.x, (int)FrameSize.y), false);
        enemySprite.SetAnimCompleteDelegate(OnAnimateComplete);

        Vector2 spriteSize = spriteManager.PixelSpaceToUVSpace((int)FrameSize.x, (int)FrameSize.y);

        //Idle animation
        UVAnimation idleAnimation  = new UVAnimation();
        Vector2     idleStartPosUV = spriteManager.PixelCoordToUVCoord((int)idleStartPos.x, (int)idleStartPos.y);

        idleAnimation.BuildUVAnim(idleStartPosUV, spriteSize, (int)idleSpriteSheetPos.x, (int)idleSpriteSheetPos.y, (int)idleAnimLength, fps);
        idleAnimation.loopCycles = -1;
        idleAnimation.name       = "idle";
        enemySprite.AddAnimation(idleAnimation);

        //Walk animation
        UVAnimation walkAnimation  = new UVAnimation();
        Vector2     walkStartPosUV = spriteManager.PixelCoordToUVCoord((int)walkStartPos.x, (int)walkStartPos.y);

        walkAnimation.BuildUVAnim(walkStartPosUV, spriteSize, (int)walkSpriteSheetPos.x, (int)walkSpriteSheetPos.y, (int)walkAnimLength, fps);
        walkAnimation.loopCycles = -1;
        walkAnimation.name       = "walk";
        enemySprite.AddAnimation(walkAnimation);

        //Shoot animation
        UVAnimation shootAnimation  = new UVAnimation();
        Vector2     shootStartPosUV = spriteManager.PixelCoordToUVCoord((int)shootStartPos.x, (int)shootStartPos.y);

        shootAnimation.BuildUVAnim(shootStartPosUV, spriteSize, (int)shootSpriteSheetPos.x, (int)shootSpriteSheetPos.y, (int)shootAnimLength, fps);
        shootAnimation.loopCycles = 0;
        shootAnimation.name       = "shoot";
        enemySprite.AddAnimation(shootAnimation);

        //Die animation
        UVAnimation dieAnimation  = new UVAnimation();
        Vector2     dieStartPosUV = spriteManager.PixelCoordToUVCoord((int)dieStartPos.x, (int)dieStartPos.y);

        dieAnimation.BuildUVAnim(dieStartPosUV, spriteSize, (int)dieSpriteSheetPos.x, (int)dieSpriteSheetPos.y, (int)dieAnimLength, fps);
        dieAnimation.loopCycles = 0;
        dieAnimation.name       = "die";
        enemySprite.AddAnimation(dieAnimation);


        gameObject.transform.position = startPos;
    }
Ejemplo n.º 29
0
    // Use this for initialization
    void Start()
    {
        width = collider.bounds.size.x * 2 + 0.15f;
        height = collider.bounds.size.y * 2 + 0.15f;

        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);

        // Create and setup anims
        UVAnimation anim = new UVAnimation();
        var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 11, 15);
        anim.name = "Idle";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);
        sprite.PlayAnim("Idle");
    }
Ejemplo n.º 30
0
	public void DrawAnimation() {
		// Put sprite on the client object
		GameObject totem = GameObject.Find("TotemMono");
		totem.renderer.enabled = false;
		Sprite totemSprite = spriteManager.AddSprite(totem, 1f, 1f, new Vector2(0, 0.5f), new Vector2(0.5f, 0.5f), Vector3.zero, false);
		
		// Set up animation
		UVAnimation anim = new UVAnimation();
		anim.name = "animation1";
		anim.loopCycles = -1;
		anim.framerate = framerate;
		
		anim.BuildUVAnim(new Vector2(0, 0.5f), new Vector2(0.5f, 0.5f), 2, 2, 4, framerate);
		
		// Prepare sprite
		totemSprite.AddAnimation(anim);
		totemSprite.PlayAnim("animation1");
	}
Ejemplo n.º 31
0
    // Use this for initialization
    void Start()
    {
        width  = collider.bounds.size.x * 2 + 0.15f;
        height = collider.bounds.size.y * 2 + 0.15f;

        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);

        // Create and setup anims
        UVAnimation anim       = new UVAnimation();
        var         firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        var         cellSize   = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));

        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 11, 15);
        anim.name       = "Idle";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);
        sprite.PlayAnim("Idle");
    }
Ejemplo n.º 32
0
    protected override void initialize()
    {
        wanderCenter = transform.position;
        InvokeRepeating("targetNearChar", 1f, 1f);
        InvokeRepeating("setWanderingPos", 0.0001f, 1f);

        sm = GameObject.Find("_SpriteManager").GetComponent <LinkedSpriteManager>();

        sprite = sm.AddSprite(this.gameObject, 1.5f, 1.5f, sm.PixelCoordToUVCoord(7 * 96, 6 * 96), sm.PixelSpaceToUVSpace(96, 96), Vector3.zero, false);
        //sprite = sm.AddSprite(this.gameObject, 2f, 2f, 0, 48, 48, 48, false);
        walkRight = new UVAnimation();
        walkRight.BuildUVAnim(sm.PixelCoordToUVCoord(0, 6 * 96), sm.PixelSpaceToUVSpace(96, 96), 8, 1, 8, 10f);
        walkRight.loopCycles = -1;
        sprite.AddAnimation(walkRight);

        walkLeft = new UVAnimation();
        walkLeft.BuildUVAnim(sm.PixelCoordToUVCoord(0 * 96, 7 * 96), sm.PixelSpaceToUVSpace(96, 96), 8, 1, 8, 10f);
        walkLeft.loopCycles = -1;
        sprite.AddAnimation(walkLeft);

        standRight = new UVAnimation();
        standRight.BuildUVAnim(sm.PixelCoordToUVCoord(7 * 96, 6 * 96), sm.PixelSpaceToUVSpace(96, 96), 2, 1, 2, 1f);
        standRight.loopCycles = -1;
        sprite.AddAnimation(standRight);

        standLeft = new UVAnimation();
        standLeft.BuildUVAnim(sm.PixelCoordToUVCoord(7 * 96, 7 * 96), sm.PixelSpaceToUVSpace(96, 96), 2, 1, 2, 1f);
        standLeft.loopCycles = -1;
        sprite.AddAnimation(standLeft);

        attackRight = new UVAnimation();
        attackRight.BuildUVAnim(sm.PixelCoordToUVCoord(8 * 96, 6 * 96), sm.PixelSpaceToUVSpace(96, 96), 2, 1, 2, 4f);
        attackRight.loopCycles = 0;
        sprite.AddAnimation(attackRight);

        attackLeft = new UVAnimation();
        attackLeft.BuildUVAnim(sm.PixelCoordToUVCoord(8 * 96, 7 * 96), sm.PixelSpaceToUVSpace(96, 96), 2, 1, 2, 4f);
        attackLeft.loopCycles = 0;
        sprite.AddAnimation(attackLeft);

        state = (int)State.SEEKING;
    }
    // Use this for initialization
    void Start()
    {
        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);

        // Create and setup anims
        UVAnimation anim = new UVAnimation();
        var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 10, 15);
        anim.name = "Idle";
        anim.loopCycles = 0;

        sprite.AddAnimation(anim);
        sprite.PlayAnim("Idle");

        sprite.SetAnimCompleteDelegate(delegate()
        {
            Destroy(transform.parent.gameObject);
        });
    }
Ejemplo n.º 34
0
    // Use this for initialization
    void Start()
    {
        spriteManager = gameObject.GetComponent <SpriteManager>() as SpriteManager;

        particleSprite = spriteManager.AddSprite(gameObject, 1.0f, 1.0f, spriteManager.PixelSpaceToUVSpace(128, 128), spriteManager.PixelSpaceToUVSpace(30, 30), false);
        particleSprite.SetAnimCompleteDelegate(OnAnimateComplete);

        Vector2 spriteSize = spriteManager.PixelSpaceToUVSpace(30, 30);

        //Idle animation
        UVAnimation idleAnimation  = new UVAnimation();
        Vector2     idleStartPosUV = spriteManager.PixelCoordToUVCoord(0, 30);

        idleAnimation.BuildUVAnim(idleStartPosUV, spriteSize, 3, 2, 5, 15);
        idleAnimation.loopCycles = 0;
        idleAnimation.name       = "idle";
        particleSprite.AddAnimation(idleAnimation);
        particleSprite.PlayAnim("idle");
        transform.position = new Vector3(startPos.x, startPos.y, startPos.z);
    }
Ejemplo n.º 35
0
    // Use this for initialization
    void Start()
    {
        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);

        // Create and setup anims
        UVAnimation anim       = new UVAnimation();
        var         firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        var         cellSize   = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));

        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 10, 15);
        anim.name       = "Idle";
        anim.loopCycles = 0;

        sprite.AddAnimation(anim);
        sprite.PlayAnim("Idle");

        sprite.SetAnimCompleteDelegate(delegate()
        {
            Destroy(transform.parent.gameObject);
        });
    }
Ejemplo n.º 36
0
    protected virtual void initialize()
    {
        crosshair = transform.Find("Crosshair").GetComponent <UISprite>();
        abilities[0].crosshair = crosshair.transform;

        rigidbody.freezeRotation = true;
        sm = GameObject.Find("_SpriteManager2").GetComponent <LinkedSpriteManager>();

        sprite = sm.AddSprite(this.gameObject, 1.5f, 1.5f, sm.PixelCoordToUVCoord(7 * 192, 192), sm.PixelSpaceToUVSpace(192, 192), Vector3.zero, false);

        walkRight = new UVAnimation();
        walkRight.BuildUVAnim(sm.PixelCoordToUVCoord(0, 192), sm.PixelSpaceToUVSpace(192, 192), 8, 1, 8, 10f);
        walkRight.loopCycles = -1;
        sprite.AddAnimation(walkRight);

        walkLeft = new UVAnimation();
        walkLeft.BuildUVAnim(sm.PixelCoordToUVCoord(0 * 192, 384), sm.PixelSpaceToUVSpace(192, 192), 8, 1, 8, 10f);
        walkLeft.loopCycles = -1;
        sprite.AddAnimation(walkLeft);

        standRight = new UVAnimation();
        standRight.BuildUVAnim(sm.PixelCoordToUVCoord(7 * 192, 192), sm.PixelSpaceToUVSpace(192, 192), 2, 1, 2, 1f);
        standRight.loopCycles = -1;
        sprite.AddAnimation(standRight);

        standLeft = new UVAnimation();
        standLeft.BuildUVAnim(sm.PixelCoordToUVCoord(7 * 192, 384), sm.PixelSpaceToUVSpace(192, 192), 2, 1, 2, 1f);
        standLeft.loopCycles = -1;
        sprite.AddAnimation(standLeft);

        attackRight = new UVAnimation();
        attackRight.BuildUVAnim(sm.PixelCoordToUVCoord(8 * 192, 192), sm.PixelSpaceToUVSpace(192, 192), 2, 1, 2, 4f);
        attackRight.loopCycles = 0;
        sprite.AddAnimation(attackRight);

        attackLeft = new UVAnimation();
        attackLeft.BuildUVAnim(sm.PixelCoordToUVCoord(8 * 192, 384), sm.PixelSpaceToUVSpace(192, 192), 2, 1, 2, 4f);
        attackLeft.loopCycles = 0;
        sprite.AddAnimation(attackLeft);
    }
Ejemplo n.º 37
0
    protected virtual void initialize()
    {
        InvokeRepeating("targetNearMob", 1f, 2f);
        sm = GameObject.Find("_SpriteManager").GetComponent <LinkedSpriteManager>();

        sprite = sm.AddSprite(this.gameObject, 1.5f, 1.5f, sm.PixelCoordToUVCoord(7 * 96, 96), sm.PixelSpaceToUVSpace(96, 96), Vector3.zero, false);
        //sprite = sm.AddSprite(this.gameObject, 2f, 2f, 0, 48, 48, 48, false);
        walkRight = new UVAnimation();
        walkRight.BuildUVAnim(sm.PixelCoordToUVCoord(0, 96), sm.PixelSpaceToUVSpace(96, 96), 8, 1, 8, 10f);
        walkRight.loopCycles = -1;
        sprite.AddAnimation(walkRight);

        walkLeft = new UVAnimation();
        walkLeft.BuildUVAnim(sm.PixelCoordToUVCoord(0 * 96, 192), sm.PixelSpaceToUVSpace(96, 96), 8, 1, 8, 10f);
        walkLeft.loopCycles = -1;
        sprite.AddAnimation(walkLeft);

        standRight = new UVAnimation();
        standRight.BuildUVAnim(sm.PixelCoordToUVCoord(7 * 96, 96), sm.PixelSpaceToUVSpace(96, 96), 2, 1, 2, 1f);
        standRight.loopCycles = -1;
        sprite.AddAnimation(standRight);

        standLeft = new UVAnimation();
        standLeft.BuildUVAnim(sm.PixelCoordToUVCoord(7 * 96, 192), sm.PixelSpaceToUVSpace(96, 96), 2, 1, 2, 1f);
        standLeft.loopCycles = -1;
        sprite.AddAnimation(standLeft);

        attackRight = new UVAnimation();
        attackRight.BuildUVAnim(sm.PixelCoordToUVCoord(8 * 96, 96), sm.PixelSpaceToUVSpace(96, 96), 2, 1, 2, 4f);
        attackRight.loopCycles = 0;
        sprite.AddAnimation(attackRight);

        attackLeft = new UVAnimation();
        attackLeft.BuildUVAnim(sm.PixelCoordToUVCoord(8 * 96, 192), sm.PixelSpaceToUVSpace(96, 96), 2, 1, 2, 4f);
        attackLeft.loopCycles = 0;
        sprite.AddAnimation(attackLeft);

        state = (int)State.SEEKING;
    }
Ejemplo n.º 38
0
    protected override void createAnimations()
    {
        // Set up standing animation
        standAnim            = new UVAnimation();
        standAnim.name       = "EighthNote Standing Animation";
        standAnim.loopCycles = -1;
        standAnim.framerate  = 24;

        standAnim.BuildUVAnim(new Vector2(0f, 10f / numRows), cellSize, 18, 1, 18, 24);
        sprite.AddAnimation(standAnim);

        // Set up moving animation
        moveAnim            = new UVAnimation();
        moveAnim.name       = "EighthNote Moving Animation";
        moveAnim.loopCycles = -1;
        moveAnim.framerate  = 24;

        moveAnim.BuildUVAnim(new Vector2(0f, 9f / numRows), cellSize, 18, 1, 18, 24);
        sprite.AddAnimation(moveAnim);

        // Play starting animation
        playStandingAnim();
    }
    void Start()
    {
        var transTest = new GameObject("MaterialTransform_"+ this.name);

        transTest.transform.position = transform.TransformPoint(transTest.transform.position);
        transTest.transform.position += new Vector3(0, 0, _depthLayer) * _depthScaleFactor;

        transTest.transform.localScale = new Vector3(_scaleX, _scaleY, 0.5f);

        _sprite = _spriteManager.AddSprite(transTest, _width, _height, 0, (int)_cellSize.x-1, (int)_cellSize.x, (int)_cellSize.x, false);

        for (var i = 0; i < _anims.Length; i++)
        {
            var anim = new UVAnimation();

            var firstFrameCoords = new Vector2(
                //_anims[i].firstFrame.x * _cellSize.x,
                0,
                _anims[i].firstFrame.y * _cellSize.y);

            var firstFrame = _spriteManager.PixelCoordToUVCoord(firstFrameCoords);
            var cellSize = _spriteManager.PixelSpaceToUVSpace(_cellSize);
            anim.BuildUVAnim(firstFrame, cellSize, _anims[i].columns, _anims[i].rows, _anims[i].totalCells, _anims[i].fps, (int)(_anims[i].firstFrame.x));
            anim.name = _anims[i].name;
            anim.loopCycles = _anims[i].loopCycles;
            _sprite.AddAnimation(anim);
        }

        _currentAnimation = _defaultAnimation;
        _sprite.PlayAnim(_defaultAnimation);
    }
Ejemplo n.º 40
0
    protected List<Affector> InitAffectors(EffectNode node)
    {
        List<Affector> AffectorList = new List<Affector>();

        if (UVAffectorEnable)
        {
            UVAnimation uvAnim = new UVAnimation();
            if (UVType == 1)
            {
                float perWidth = OriUVDimensions.x / Cols;
                float perHeight = Mathf.Abs(OriUVDimensions.y / Rows);
                Vector2 cellSize = new Vector2(perWidth, perHeight);
                uvAnim.BuildUVAnim(OriTopLeftUV, cellSize, Cols, Rows, Cols * Rows);
            }
            UVDimension = uvAnim.UVDimensions[0];
            UVTopLeft = uvAnim.frames[0];

            if (uvAnim.frames.Length != 1)
            {
                uvAnim.loopCycles = LoopCircles;
                Affector aft = new UVAffector(uvAnim, UVTime, node, RandomStartFrame);
                AffectorList.Add(aft);
            }
        }
        else
        {
            UVDimension = OriUVDimensions;
            UVTopLeft = OriTopLeftUV;
        }

        if (RotAffectorEnable && RotateType != RSTYPE.NONE)
        {
            Affector aft;
            if (RotateType == RSTYPE.CURVE)
                aft = new RotateAffector(RotateCurve, node);
            else
                aft = new RotateAffector(DeltaRot, node);
            AffectorList.Add(aft);
        }
        if (ScaleAffectorEnable && ScaleType != RSTYPE.NONE)
        {
            Affector aft;

            if (UseSameScaleCurve)
                ScaleYCurve = ScaleXCurve;

            if (ScaleType == RSTYPE.CURVE)
                aft = new ScaleAffector(ScaleXCurve, ScaleYCurve, node);
            else
                aft = new ScaleAffector(DeltaScaleX, DeltaScaleY, node);
            AffectorList.Add(aft);
        }
        if (ColorAffectorEnable /*&& ColorAffectType != 0*/)
        {
            ColorAffector aft = new ColorAffector(this, node);
            AffectorList.Add(aft);
        }
        if (JetAffectorEnable)
        {
            Affector aft = new JetAffector(JetMag,JetMagType,JetCurve,node);
            AffectorList.Add(aft);
        }
        if (VortexAffectorEnable)
        {
            Affector aft;
            aft = new VortexAffector(VortexObj, VortexMagType, VortexMag, VortexCurve, VortexDirection, VortexInheritRotation, node);

            AffectorList.Add(aft);
        }
        if (UVRotAffectorEnable)
        {
            Affector aft;

            float xscroll = UVRotXSpeed;
            float yscroll = UVRotYSpeed;
            if (RandomUVRotateSpeed)
            {
                xscroll = Random.Range(UVRotXSpeed,UVRotXSpeedMax);
                yscroll = Random.Range(UVRotYSpeed,UVRotYSpeedMax);
            }

            aft = new UVRotAffector(xscroll, yscroll, node);
            AffectorList.Add(aft);
        }

        if (GravityAffectorEnable)
        {
            Affector aft;
            aft = new GravityAffector(GravityObject, GravityAftType, GravityMagType, IsGravityAccelerate,GravityDirection, GravityMag, GravityCurve, node);
            AffectorList.Add(aft);

            if (GravityAftType == GAFTTYPE.Spherical && GravityObject == null)
            {
                Debug.LogWarning("Gravity Object is missing, automatically set to effect layer self:" + gameObject.name);
                GravityObject = transform;
            }

        }
        if (AirAffectorEnable)
        {
            Affector aft = new AirFieldAffector(AirObject, AirDirection, AirMagType, AirMagnitude, AirMagCurve, AirAttenuation, AirUseMaxDistance,
                AirMaxDistance, AirEnableSpread, AirSpread, AirInheritVelocity, AirInheritRotation, node);
            AffectorList.Add(aft);
        }
        if (BombAffectorEnable)
        {
            Affector aft = new BombAffector(BombObject, BombType, BombMagType, BombDecayType, BombMagnitude, BombMagCurve, BombDecay, BombAxis, node);
            AffectorList.Add(aft);
        }
        if (TurbulenceAffectorEnable)
        {
            Affector aft = new TurbulenceFieldAffector(TurbulenceObject, TurbulenceMagType, TurbulenceMagnitude, TurbulenceMagCurve, TurbulenceAttenuation, TurbulenceUseMaxDistance, TurbulenceMaxDistance, node);
            AffectorList.Add(aft);
        }
        if (DragAffectorEnable)
        {
            Affector aft = new DragAffector(DragObj,DragUseDir,DragDir,DragMag,DragUseMaxDist,DragMaxDist,DragAtten,node);
            AffectorList.Add(aft);
        }
        return AffectorList;
    }
Ejemplo n.º 41
0
    public void Initialize(DungeonEntity e, SpriteData sd, LinkedSpriteManager ls)
    {
        entity = e;
        spriteData = sd;
        lsManager = ls;
        Texture texture = lsManager.material.mainTexture;
        Vector2 textDim = new Vector2(texture.width, texture.height);
        uvDim = new Vector2(spriteData.spriteDim.x / textDim.x, spriteData.spriteDim.y / textDim.y);
        Vector2 uvCoord = Vector2.zero;
        uvCoord.x = uvDim.x * 7;
        uvCoord.y = 1 - (spriteData.spriteDim.y * (spriteData.spriteIndex + 1) / textDim.y);
        sprite = lsManager.AddSprite(gameObject, spriteData.dim.x, spriteData.dim.y, uvCoord, uvDim, Vector3.up * 0.5f, true);
        visible = true;

        transform.localPosition = Vector3.up * sd.dim.y/2;

        Vector2 pos;

        UVAnimation walking_s = new UVAnimation();
        pos = new Vector2(0, uvCoord.y);
        walking_s.BuildUVAnim(pos, uvDim, 3, 1, 3, 10);
        walking_s.name = "walking_s";
        walking_s.loopCycles = -1;

        UVAnimation walking_nw = new UVAnimation();
        pos = new Vector2(uvDim.x * 3, uvCoord.y);
        walking_nw.BuildUVAnim(pos, uvDim, 3, 1, 3, 10);
        walking_nw.name = "walking_nw";
        walking_nw.loopCycles = -1;

        UVAnimation walking_sw = new UVAnimation();
        pos = new Vector2(uvDim.x * 3, uvCoord.y);
        walking_sw.BuildUVAnim(pos, uvDim, 3, 1, 3, 10);
        walking_sw.name = "walking_sw";
        walking_sw.loopCycles = -1;

        UVAnimation walking_ne = new UVAnimation();
        pos = new Vector2(uvDim.x * 6, uvCoord.y);
        walking_ne.BuildUVAnim(pos, uvDim, 3, 1, 3, 10);
        walking_ne.name = "walking_ne";
        walking_ne.loopCycles = -1;

        UVAnimation walking_se = new UVAnimation();
        pos = new Vector2(uvDim.x * 6, uvCoord.y);
        walking_se.BuildUVAnim(pos, uvDim, 3, 1, 3, 10);
        walking_se.name = "walking_se";
        walking_se.loopCycles = -1;

        UVAnimation walking_n = new UVAnimation();
        pos = new Vector2(uvDim.x * 9, uvCoord.y);
        walking_n.BuildUVAnim(pos, uvDim, 3, 1, 3, 10);
        walking_n.name = "walking_n";
        walking_n.loopCycles = -1;

        sprite.AddAnimation(walking_n);
        sprite.AddAnimation(walking_ne);
        sprite.AddAnimation(walking_nw);
        sprite.AddAnimation(walking_s);
        sprite.AddAnimation(walking_se);
        sprite.AddAnimation(walking_sw);
    }
Ejemplo n.º 42
0
    void InitSM()
    {
        S = LSM.AddSprite(this.gameObject, 5, 5, LSM.PixelCoordToUVCoord(0, 0), LSM.PixelSpaceToUVSpace(512, 512), -transform.forward * .4f, false);
        anim_run = new UVAnimation();
        anim_run.SetAnim(
            new Vector2[]{
                LSM.PixelCoordToUVCoord(3072, 0),
                LSM.PixelCoordToUVCoord(3072+512, 0),
                LSM.PixelCoordToUVCoord(0, 512),
                LSM.PixelCoordToUVCoord(512, 512),
                LSM.PixelCoordToUVCoord(1024, 512),
                LSM.PixelCoordToUVCoord(1024+512, 512),
                LSM.PixelCoordToUVCoord(2048, 512),
                LSM.PixelCoordToUVCoord(2048+512, 512)
            });
        //anim_run.BuildUVAnim(LSM.PixelCoordToUVCoord(3072, 512), LSM.PixelSpaceToUVSpace(512, 512), 16, 2, 16, 2f);
        anim_run.loopCycles = -1;
        //anim_run.PlayInReverse();
        anim_run.name = "Run";
        S.AddAnimation(anim_run);

        anim_idle = new UVAnimation();
        anim_idle.BuildUVAnim(LSM.PixelCoordToUVCoord(0, 512), LSM.PixelCoordToUVCoord(512, 512), 8, 2, 1, 12f);
        anim_idle.loopCycles = -1;
        S.AddAnimation(anim_idle);
        anim_idle.name = "Idle";

        anim_runstart = new UVAnimation();
        anim_runstart.BuildUVAnim(LSM.PixelCoordToUVCoord(0, 512), LSM.PixelCoordToUVCoord(512, 512), 8, 2, 1, 12f);
        anim_runstart.loopCycles = -1;
        S.AddAnimation(anim_runstart);
        anim_runstart.name = "RunStart";

        anim_current = "Run";
        S.PlayAnim(anim_run);
        LSM.ScheduleBoundsUpdate(0.5f);
    }
    public override void Start()
    {
        base.Start();

        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);

        // Create and setup anims
        UVAnimation anim = new UVAnimation();
        var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 14, 15);
        anim.name = "Idle";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);

        anim = new UVAnimation();
        firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 383));
        cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 16, 15);
        anim.name = "Die";
        anim.loopCycles = 0;

        sprite.AddAnimation(anim);

        sprite.PlayAnim("Idle");

        dolphin = GameObject.Find("DolphinSprite");
        Util.Assert(dolphin != null);
    }
Ejemplo n.º 44
0
    void Start()
    {
        spriteManager = spriteManagerObject.GetComponent<SpriteManager>();

        bullets = new Bullet[numberOfBullets];
        for(int i = 0; i < numberOfBullets; i++)
        {
            Bullet bullet = new Bullet();
            Rigidbody brigidbody = Instantiate(bulletPrefab, Vector3.zero, Quaternion.identity) as Rigidbody;
            brigidbody.transform.parent = transform;
            brigidbody.gameObject.SetActive(false);
            bullet.rigidbody = brigidbody;

            bullet.sprite = spriteManager.AddSprite(bullet.rigidbody.gameObject, 2f, 2f, 0, 512, 512, 512, true);

            UVAnimation animation = new UVAnimation();
            Vector2 randomFacingUV = (UnityEngine.Random.value >= 0.5f) ? new Vector2(0, 0.5f) : new Vector2(0.5f, 0);
            animation.BuildUVAnim(randomFacingUV, new Vector2(0.5f, 0.5f), 2, 1, 2, 8);
            animation.loopCycles = 3000;
            bullet.sprite.PlayAnim(animation);
            spriteManager.AnimateSprite(bullet.sprite);

            bullets[i] = bullet;
        }

        GameManager.RegisterPlayer(gameObject);

        swarm = swarmObject.GetComponent<SwarmScript>();
    }
Ejemplo n.º 45
0
    protected ArrayList InitAffectors(EffectNode node)
    {
        ArrayList AffectorList = new ArrayList();

        if (UVAffectorEnable)
        {
            UVAnimation uvAnim = new UVAnimation();
            if (UVType == 1)
            {
                float perWidth = OriUVDimensions.x / Cols;
                float perHeight = Mathf.Abs(OriUVDimensions.y / Rows);
                Vector2 cellSize = new Vector2(perWidth, perHeight);
                uvAnim.BuildUVAnim(OriTopLeftUV, cellSize, Cols, Rows, Cols * Rows);
            }
            UVDimension = uvAnim.UVDimensions[0];
            UVTopLeft = uvAnim.frames[0];

            if (uvAnim.frames.Length != 1)
            {
                uvAnim.loopCycles = LoopCircles;
                Affector aft = new UVAffector(uvAnim, UVTime, node, RandomStartFrame);
                AffectorList.Add(aft);
            }
        }
        else
        {
            UVDimension = OriUVDimensions;
            UVTopLeft = OriTopLeftUV;
        }

        if (RotAffectorEnable && RotateType != RSTYPE.NONE)
        {
            Affector aft;
            if (RotateType == RSTYPE.CURVE)
                aft = new RotateAffector(RotateCurve, node);
            else
                aft = new RotateAffector(DeltaRot, node);
            AffectorList.Add(aft);
        }
        if (ScaleAffectorEnable && ScaleType != RSTYPE.NONE)
        {
            Affector aft;
            if (ScaleType == RSTYPE.CURVE)
                aft = new ScaleAffector(ScaleXCurve, ScaleYCurve, node);
            else
                aft = new ScaleAffector(DeltaScaleX, DeltaScaleY, node);
            AffectorList.Add(aft);
        }
        if (ColorAffectorEnable && ColorAffectType != 0)
        {
            ColorAffector aft;
            if (ColorAffectType == 2)
            {
                Color[] carr = new Color[5];
                carr[0] = Color1; carr[1] = Color2; carr[2] = Color3; carr[3] = Color4; carr[4] = Color5;
                aft = new ColorAffector(carr, ColorGradualTimeLength, ColorGradualType, node);
            }
            else
            {
                Color[] carr = new Color[2];
                carr[0] = Color1; carr[1] = Color2;
                aft = new ColorAffector(carr, ColorGradualTimeLength, ColorGradualType, node);
            }
            AffectorList.Add(aft);
        }
        if (JetAffectorEnable)
        {
            Affector aft = new JetAffector(JetMin, JetMax, node);
            AffectorList.Add(aft);
        }
        if (VortexAffectorEnable)
        {
            Affector aft;
            aft = new VortexAffector(VortexObj, VortexMagType, VortexMag, VortexCurve, VortexDirection, VortexInheritRotation, node);

            AffectorList.Add(aft);
        }
        if (UVRotAffectorEnable)
        {
            Affector aft;
            aft = new UVRotAffector(UVRotXSpeed, UVRotYSpeed, node);
            AffectorList.Add(aft);
        }

        if (GravityAffectorEnable)
        {
            Affector aft;
            aft = new GravityAffector(GravityObject, GravityAftType, GravityMagType, IsGravityAccelerate,GravityDirection, GravityMag, GravityCurve, node);
            AffectorList.Add(aft);

            if (GravityAftType == GAFTTYPE.Spherical && GravityObject == null)
            {
                Debug.LogWarning("Gravity Object is missing, automatically set to effect layer self.");
                GravityObject = transform;
            }

        }
        if (AirAffectorEnable)
        {
            Affector aft = new AirFieldAffector(AirObject, AirDirection, AirMagType, AirMagnitude, AirMagCurve, AirAttenuation, AirUseMaxDistance,
                AirMaxDistance, AirEnableSpread, AirSpread, AirInheritVelocity, AirInheritRotation, node);
            AffectorList.Add(aft);
        }
        if (BombAffectorEnable)
        {
            Affector aft = new BombAffector(BombObject, BombType, BombMagType, BombDecayType, BombMagnitude, BombMagCurve, BombDecay, BombAxis, node);
            AffectorList.Add(aft);
        }
        if (TurbulenceAffectorEnable)
        {
            Affector aft = new TurbulenceFieldAffector(TurbulenceObject, TurbulenceMagType, TurbulenceMagnitude, TurbulenceMagCurve, TurbulenceAttenuation, TurbulenceUseMaxDistance, TurbulenceMaxDistance, node);
            AffectorList.Add(aft);
        }
        return AffectorList;
    }
Ejemplo n.º 46
0
    protected ArrayList InitAffectors(EffectNode node)
    {
        ArrayList AffectorList = new ArrayList();

        if (UVAffectorEnable)
        {
            UVAnimation uvAnim = new UVAnimation();
            Texture t = Vertexpool.GetMaterial().GetTexture("_MainTex");

            if (UVType == 2)
            {
                uvAnim.BuildFromFile(EanPath, EanIndex, UVTime, t);
                OriLowerLeftUV = uvAnim.frames[0];
                OriUVDimensions = uvAnim.UVDimensions[0];
            }
            else if (UVType == 1)
            {
                float perWidth = t.width / Cols;
                float perHeight = t.height / Rows;
                Vector2 cellSize = new Vector2(perWidth / t.width, perHeight / t.height);
                Vector2 start = new Vector2(0f, 1f);
                uvAnim.BuildUVAnim(start, cellSize, Cols, Rows, Cols * Rows);
                OriLowerLeftUV = start;
                OriUVDimensions = cellSize;
                OriUVDimensions.y = -OriUVDimensions.y;
            }

            if (uvAnim.frames.Length == 1)
            {
                OriLowerLeftUV = uvAnim.frames[0];
                OriUVDimensions = uvAnim.UVDimensions[0];
            }
            else
            {
                uvAnim.loopCycles = LoopCircles;
                Affector aft = new UVAffector(uvAnim, UVTime,node);
                AffectorList.Add(aft);
            }
        }

        if (RotAffectorEnable && RotateType != RSTYPE.NONE)
        {
            Affector aft;
            if (RotateType == RSTYPE.CURVE)
                aft = new RotateAffector(RotateCurve,node);
            else
                aft = new RotateAffector(DeltaRot,node);
            AffectorList.Add(aft);
        }
        if (ScaleAffectorEnable && ScaleType != RSTYPE.NONE)
        {
            Affector aft;
            if (ScaleType == RSTYPE.CURVE)
                aft = new ScaleAffector(ScaleXCurve,ScaleYCurve,node);
            else
                aft = new ScaleAffector(DeltaScaleX, DeltaScaleY,node);
            AffectorList.Add(aft);
        }
        if (ColorAffectorEnable && ColorAffectType != 0)
        {
            ColorAffector aft;
            if (ColorAffectType == 2)
            {
                Color[] carr = new Color[4];
                carr[0] = Color1; carr[1] = Color2; carr[2] = Color3; carr[3] = Color4;
                aft = new ColorAffector(carr,ColorGradualTimeLength,ColorGradualType,node);
            }
            else
            {
                Color[] carr = new Color[2];
                carr[0] = Color1; carr[1] = Color2;
                aft = new ColorAffector(carr,ColorGradualTimeLength,ColorGradualType,node);
            }
            AffectorList.Add(aft);
        }
        if (LinearForceAffectorEnable)
        {
            Affector aft = new LinearForceAffector(LinearForce.normalized * LinearMagnitude,node);
            AffectorList.Add(aft);
        }
        if (JetAffectorEnable)
        {
            Affector aft = new JetAffector(JetMin,JetMax,node);
            AffectorList.Add(aft);
        }
        if (VortexAffectorEnable)
        {
            Affector aft;
            if (UseVortexCurve)
                aft = new VortexAffector(VortexCurve, VortexDirection,node);
            else
                aft = new VortexAffector(VortexMag, VortexDirection,node);
            AffectorList.Add(aft);
        }
        if (AttractionAffectorEnable)
        {
            Affector aft ;
            if (UseVortexCurve)
                aft = new AttractionForceAffector(AttractionCurve, AttractionPosition,node);
            else
                aft = new AttractionForceAffector(AttractMag, AttractionPosition,node);
            AffectorList.Add(aft);
        }

        return AffectorList;
    }