Exemplo n.º 1
0
    public void ChangeDirection()
    {
        //	dirRotation = Vector3.Angle(this.GetPosition(), curEnemy.GetPos ());
        dirRotation = Vector3.Angle(dirPos, Vector3.right);
        QuadTextureNgui tex = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>();

        if (dirRotation >= 0.0f && dirRotation <= 180f)
        {
            int angle = ((int)(dirRotation / 10.0f) * 10);
            if (angle == 0)
            {
                tex.mSpriteName = data.level + "0000";
            }
            else if (10 <= angle && angle < 100)
            {
                tex.mSpriteName = data.level + "00" + angle;
            }
            else
            {
                tex.mSpriteName = data.level + "0" + angle;
            }
            if (dirPos.z >= 0)
            {
                tex.mirrorX = true;
            }
            else
            {
                tex.mirrorX = false;
            }
            tex.InitFace();
        }
    }
Exemplo n.º 2
0
    public void RebuildSpriteList(bool first = false)
    {
        if (mSprite == null)
        {
            mSprite = GetComponent <QuadTextureNgui>();
        }
        mSpriteNames.Clear();
        if (first == false)
        {
            OnNormalAniFinished = null;
        }

        if (mSprite != null && mSprite.Atlas != null)
        {
            List <UISpriteData> sprites = mSprite.Atlas.spriteList;

            for (int i = 0, imax = sprites.Count; i < imax; ++i)
            {
                UISpriteData sprite = sprites[i];

                if (string.IsNullOrEmpty(namePrefix) || sprite.name.StartsWith(namePrefix))
                {
                    mSpriteNames.Add(sprite.name);
                }
            }
            //if(mSpriteNames.Count != 0 &&  mSpriteNames[0].Contains("_"))
            //	mSpriteNames.Sort(SortByName);
        }
    }
Exemplo n.º 3
0
    public void DestoryAni()
    {
        QuadTextureNgui tex = transform.GetChild(0).GetComponent <QuadTextureNgui>();

        for (int i = 1; i <= 9; i++)
        {
            tex.mSpriteName = "Death001" + i;
            tex.mirrorX     = false;
            tex.InitFace();
        }
    }
Exemplo n.º 4
0
    void HitAnimation()
    {
        Debug.Log("33");
        if (endAttack || canAttack == false)
        {
            return;
        }
        mHitDelta += RealTime.deltaTime;
        float rate = 0.5f;

        if (rate < mHitDelta)
        {
            mHitDelta = (rate > 0f) ? mHitDelta - rate : 0f;
            if (curFps > 0)
            {
                Debug.Log("11");
                curFps = 0;
                GetTransform().GetChild(0).localPosition = new Vector3(0.0f, 0.3f, 0.0f);
                QuadTextureNgui gui = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>();
                gui.ScaleFactor = 0.5f;

                endAttack = true;
                canAttack = false;
            }
            else
            {
                Debug.Log("22");
                GameObject   bulletgo = (GameObject)GameObject.Instantiate(Resources.Load("cannonbullet"));
                CannonBullet bullet   = bulletgo.GetComponent <CannonBullet>();
                bulletgo.transform.position = GetTransform().position + GetTransform().forward * 0.6f;
                bullet.parent = this;
                curEnemy      = EnemySpawnManager._instance.enemyList[0];

                bullet.Fire(curEnemy);
                Vector3 dir = Vector3.back * moveDistance;
                GetTransform().GetChild(0).localPosition = new Vector3(dir.x, dir.y + 0.3f, dir.z);
                QuadTextureNgui gui = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>();
                gui.ScaleFactor = scalefactor;
                curFps++;
            }
        }
    }
Exemplo n.º 5
0
    public void ChangeDirection()
    {
        //	dirRotation = Vector3.Angle(this.GetPosition(), curEnemy.GetPos ());
        dirRotation = Vector3.Angle(dirPos, Vector3.right);
        QuadTextureNgui tex = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>();

        if (dirRotation >= 0.0f && dirRotation <= 180f)
        {
            int angle = ((int)(dirRotation / 10.0f) * 10);
            tex.mSpriteName = "" + angle;
            tex.mirrorX     = false;
            tex.InitFace();
        }
        else if (dirRotation > 180.0f && dirRotation <= 360.0f)
        {
            int angle = ((int)((360.0f - dirRotation) / 10.0f) * 10);
            tex.mSpriteName = "" + angle;
            tex.mirrorX     = true;
            tex.InitFace();
        }
    }
Exemplo n.º 6
0
	public void RebuildSpriteList (bool first = false)
	{
		if (mSprite == null) mSprite = GetComponent<QuadTextureNgui>();
		mSpriteNames.Clear();
		if(first == false)
			OnNormalAniFinished = null;
		
		if (mSprite != null && mSprite.Atlas != null )
		{
			List<UISpriteData> sprites = mSprite.Atlas.spriteList;
			
			for (int i = 0, imax = sprites.Count; i < imax; ++i)
			{
				UISpriteData sprite = sprites[i];
				
				if (string.IsNullOrEmpty(namePrefix) || sprite.name.StartsWith(namePrefix))
				{
					mSpriteNames.Add(sprite.name);
				}
			}
			//if(mSpriteNames.Count != 0 &&  mSpriteNames[0].Contains("_"))
			//	mSpriteNames.Sort(SortByName);
		}
	}
Exemplo n.º 7
0
 void HitAnimation()
 {
     if (endAttack || canAttack == false)
     {
         return;
     }
     mHitDelta += RealTime.deltaTime;
     if (data.attackRate < mHitDelta)
     {
         mHitDelta = (data.attackRate > 0f) ? mHitDelta - data.attackRate : 0f;
         if (curFps > 0)
         {
             curFps = 0;
             GetTransform().GetChild(0).localPosition = new Vector3(0.0f, 0.3f, 0.0f);
             QuadTextureNgui gui = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>();
             gui.ScaleFactor = 0.5f;
             endAttack       = true;
             canAttack       = false;
         }
         else
         {
             if (curEnemy != null)
             {
                 GameObject  bulletgo = (GameObject)GameObject.Instantiate(Resources.Load("laserbullet"));
                 LaserBullet bullet   = bulletgo.GetComponent <LaserBullet>();
                 bulletgo.transform.position = GetTransform().position + GetTransform().forward * 0.6f;
                 //bulletgo.transform.position = gun.position ;
                 bullet.parent10 = this;
                 if (enemyLists.Count > 0)
                 {
                     for (int i = 0; i < EnemySpawnManager._instance.enemyList.Count; i++)
                     {
                         for (int j = 0; j < enemyLists.Count; j++)
                         {
                             if (EnemySpawnManager._instance.enemyList[i].ID == enemyLists[j].ID)
                             {
                                 curEnemy = enemyLists[j];
                                 break;
                             }
                         }
                         if (curEnemy != null)
                         {
                             break;
                         }
                     }
                     if (curEnemy != null)
                     {
                         AudioSource.PlayClipAtPoint(AudioManager._instance.tower10FireMusic, this.GetPos());
                         bullet.Fire(curEnemy);
                     }
                     Vector3 dir = Vector3.back * moveDistance;
                     GetTransform().GetChild(0).localPosition = new Vector3(dir.x, dir.y + 0.3f, dir.z);
                     QuadTextureNgui gui = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>();
                     gui.ScaleFactor = scalefactor;
                     curFps++;
                 }
                 else if (enemyLists.Count == 0)
                 {
                     curEnemy = null;
                     return;
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
 void HitAnimation()
 {
     if (endAttack || canAttack == false)
     {
         return;
     }
     mHitDelta += RealTime.deltaTime;
     if (data.attackRate < mHitDelta)
     {
         mHitDelta = (data.attackRate > 0f) ? mHitDelta - data.attackRate : 0f;
         if (curFps > 0)
         {
             curFps = 0;
             GetTransform().GetChild(0).localPosition = new Vector3(0.0f, 0.3f, 0.0f);
             QuadTextureNgui gui = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>();
             gui.ScaleFactor = 0.5f;
             endAttack       = true;
             canAttack       = false;
         }
         else
         {
             if (curEnemy != null)
             {
                 GameObject   bulletgo = (GameObject)GameObject.Instantiate(Resources.Load("cannonbullet1"));
                 CannonBullet bullet   = bulletgo.GetComponent <CannonBullet>();
                 bulletgo.transform.position = GetTransform().position + GetTransform().forward * 0.6f;
                 bullet.parent2 = this;
                 if (curEnemy != null)
                 {
                     AudioSource.PlayClipAtPoint(AudioManager._instance.tower2FireMusic, this.GetPos());
                     bullet.Fire(curEnemy);
                 }
                 Vector3 dir = Vector3.back * moveDistance;
                 GetTransform().GetChild(0).localPosition = new Vector3(dir.x, dir.y + 0.3f, dir.z);
                 QuadTextureNgui gui = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>();
                 gui.ScaleFactor = scalefactor;
                 curFps++;
             }
             if (secondEnemy != null)
             {
                 GameObject   bulletgo1 = (GameObject)GameObject.Instantiate(Resources.Load("cannonbullet2"));
                 CannonBullet bullet1   = bulletgo1.GetComponent <CannonBullet>();
                 bulletgo1.transform.position = GetTransform().position + GetTransform().forward * 0.6f;
                 //bulletgo.transform.position = gun.position ;
                 bullet1.parent2 = this;
                 if (secondEnemy != null)
                 {
                     bullet1.Fire(secondEnemy);
                 }
                 Vector3 dir1 = Vector3.back * moveDistance;
                 GetTransform().GetChild(0).localPosition = new Vector3(dir1.x, dir1.y + 0.3f, dir1.z);
                 QuadTextureNgui gui1 = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>();
                 gui1.ScaleFactor = scalefactor;
                 curFps++;
             }
             if (thirdEnemy != null)
             {
                 GameObject   bulletgo2 = (GameObject)GameObject.Instantiate(Resources.Load("cannonbullet3"));
                 CannonBullet bullet2   = bulletgo2.GetComponent <CannonBullet>();
                 bulletgo2.transform.position = GetTransform().position + GetTransform().forward * 0.6f;
                 //bulletgo.transform.position = gun.position ;
                 bullet2.parent2 = this;
                 if (thirdEnemy != null)
                 {
                     bullet2.Fire(thirdEnemy);
                 }
                 Vector3 dir1 = Vector3.back * moveDistance;
                 GetTransform().GetChild(0).localPosition = new Vector3(dir1.x, dir1.y + 0.3f, dir1.z);
                 QuadTextureNgui gui1 = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>();
                 gui1.ScaleFactor = scalefactor;
                 curFps++;
             }
             if (forthEnemy != null)
             {
                 GameObject   bulletgo3 = (GameObject)GameObject.Instantiate(Resources.Load("cannonbullet4"));
                 CannonBullet bullet3   = bulletgo3.GetComponent <CannonBullet>();
                 bulletgo3.transform.position = GetTransform().position + GetTransform().forward * 0.6f;
                 //bulletgo.transform.position = gun.position ;
                 bullet3.parent2 = this;
                 if (forthEnemy != null)
                 {
                     bullet3.Fire(forthEnemy);
                 }
                 Vector3 dir1 = Vector3.back * moveDistance;
                 GetTransform().GetChild(0).localPosition = new Vector3(dir1.x, dir1.y + 0.3f, dir1.z);
                 QuadTextureNgui gui1 = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>();
                 gui1.ScaleFactor = scalefactor;
                 curFps++;
             }
         }
     }
 }
Exemplo n.º 9
0
    //change the direction of the character
    public void CheckDir()
    {
        if (gameObject == null)
        {
            return;
        }
        needChangeStatus = false;
        if (mDir != _CurDir)
        {
            needChangeStatus = true;
            mDir             = _CurDir;
        }
        if (mPose != CurPose)
        {
            needChangeStatus = true;
            mPose            = CurPose;
        }
        Quaternion dir      = gameObject.transform.localRotation;
        float      curAngle = dir.eulerAngles.y % 360.0f;

        curAngle = curAngle < 0.0f ? curAngle + 360.0f : curAngle;
        //rotate the weapon
        if (rotateWeapon && CurPose != Pose.Die)
        {
            QuadTextureNgui tex = transform.GetChild(0).GetComponent <QuadTextureNgui>();
            if (curAngle >= 0.0f && curAngle <= 151f)
            {
                int angle = ((int)(curAngle / 10.0f) * 10);
                tex.mSpriteName = "" + angle;
                tex.mirrorX     = false;
                tex.InitFace();
            }
            else if (curAngle > 151.0f && curAngle <= 301.0f)
            {
                int angle = ((int)((301.0f - curAngle) / 10.0f) * 10);
                tex.mSpriteName = "" + angle;
                tex.mirrorX     = true;
                tex.InitFace();
            }
            else if (curAngle > 301.0f && curAngle <= 321.0f)
            {
                int angle = ((int)((661.0f - curAngle) / 10.0f) * 10);
                tex.mSpriteName = "" + angle;
                tex.mirrorX     = true;
                tex.InitFace();
            }
        }
        else
        {
            //will not be used
            if ((curAngle >= 0.0f && curAngle < 45.0f) || (curAngle > 315.0f && curAngle <= 360.0f))
            {
                _CurDir = Dir.RightUp;
            }
            else if (curAngle >= 270.0f && curAngle <= 315.0f)
            {
                _CurDir = Dir.LeftUp;
            }
            else if (curAngle >= 45.0f && curAngle < 90.0f)
            {
                _CurDir = Dir.Right;
            }
            else if (curAngle >= 100.0f && curAngle < 270.0f)
            {
                _CurDir = Dir.Left;
            }
            else if (curAngle >= 127.0f && curAngle < 180.0f)
            {
                _CurDir = Dir.LeftDown;
            }
            else if (curAngle >= 90.0f && curAngle < 127.0f)
            {
                _CurDir = Dir.RightDown;
            }
        }
    }