Esempio n. 1
0
    //攻击检
    void OnTriggerEnter(Collider csi)
    {
        if (csi.tag == "RigBox" && this.tag == "AtkBox")
        {
            RigBoxCtl rbc = csi.GetComponent <RigBoxCtl>();
            int       id  = rbc.parent.GetInstanceID();

            if (id != root.GetInstanceID())
            {
                CharaCtlFourFace emy = rbc.parent.GetComponent <CharaCtlFourFace>();
                if (root != null)
                {
                    CharaCtlFourFace chr = root.GetComponent <CharaCtlFourFace>();

                    if (chr != null)
                    {
                        chr.Atk(emy);
                        emy.aim = chr;
                    }
                }

                if (tagType == "Chara" && rbc.tagType == "Chara")
                {
                    Base(rbc);
                }
                else if (tagType == "Arrow" && rbc.tagType == "Chara")
                {
                    Base(rbc);
                    parent.SendMessage("OnAtk", emy, SendMessageOptions.DontRequireReceiver);
                }
            }
        }
    }
Esempio n. 2
0
    void FindNewAim()
    {
        BattleSRTM Scene = Game.SRTM <BattleSRTM>();

        int   id       = -1;
        float maxRange = float.MaxValue;

        for (int i = 0; i < Scene.chrs.Count; i++)
        {
            CharaCtlFourFace chr = Scene.chrs[i];
            if (chr.GetInstanceID() != this.GetInstanceID())
            {
                if (chr.living)
                {
                    float range = (chr.transform.localPosition - this.transform.localPosition).magnitude;
                    if (range < maxRange)
                    {
                        maxRange = range;
                        id       = i;
                    }
                }
            }
        }

        if (id != -1)
        {
            this.aim = Scene.chrs[id];
        }
    }
Esempio n. 3
0
    // Use this for initialization
    void Start()
    {
        Game.CreateSpriteClipPack("Actor1", new Point(32, 32));
        Game.CreateSpriteClipPack("Wepon", new Point(24, 24));

        int max = 8;

        for (int i = 0; i < max; i++)
        {
            CharaCtlFourFace chr = Game.Instantiate <CharaCtlFourFace>(Game.CObj("Chara"));
            chr.transform.parent        = charaPanel;
            chr.transform.localPosition = new Vector3(i * 32 - 0.5f * max * 32, GameHelp.Random(-100, 100), 0);
            chr.transform.localScale    = Vector3.one;
            chr.id = new Point(GameHelp.Random(0, 3) * 3 + 1, GameHelp.Random(0, 1) * 4 + 1);

            chr.aimMove.v  = GameHelp.Random(10, 100);
            chr.rbc.weight = GameHelp.Random(100, 200);

            CharaBaseInfo info = new CharaBaseInfo();

            info.HP  = info.MaxHP = GameHelp.Random(100, 200);
            info.Atk = GameHelp.Random(10, 20);
            info.Def = GameHelp.Random(1, 5);

            chr.info       = info;
            chr.wp.atkType = (AtkType)GameHelp.Random(2, 3);
            chr.wp.RenewWepon();

            chrs.Add(chr);
        }

        int ranId = GameHelp.Random(0, chrs.Count - 1);

        chrs[ranId].aimMove.v  = 200;
        chrs[ranId].rbc.weight = 100;

        chrs[ranId].atkSpeed = 2.5f;
        chrs[ranId].info.Atk = 30;
        chrs[ranId].info.HP  = chrs[ranId].info.MaxHP = 200;

        camAim.Aim(chrs[ranId].transform);

        /*
         * foreach(CharaCtlFourFace chr in chrs)
         * {
         *      chr.aim=chrs[GameHelp.Random(0,chrs.Count-1)].transform;
         * }*/
    }
Esempio n. 4
0
	void Update () 
	{

		if(info.HP==0 && living)
		{
			aimMove.update=false;
			aimMove.move=false;

			rbc.enabled=false;
			living=false;

			GameObject go= GameObject.Instantiate(Game.EObj("DieEff")) as GameObject;

			go.transform.parent=Game.SRTM<BattleSRTM>().charaPanel;
			go.transform.localPosition=this.transform.localPosition;
			go.transform.localScale=Vector3.one;

			Destroy(this.gameObject);
			Game.SRTM<BattleSRTM>().chrs.Remove(this);
		}

		if(aim!=null)
		{
			if(!aim.living)
			{
				aim=null;
			}

		}

		spt.depth=-(int)transform.localPosition.y;
		wp.spt.depth=spt.depth+1;

		
		if(living)
		{

			if(aim!=null)
			{
				Vector3 dis=aim.transform.localPosition-transform.localPosition;
				Vector3 aimPos=aim.transform.localPosition;

				if(wp.atkType==AtkType.Shooting)
				{
					aimPos=dis.normalized*(dis.magnitude-wp.atkRange);
				}



				aimMove.Aim(aimPos,true);

				Vector2 v2=new Vector2(dis.x,dis.y);
				angle=Vector2.Angle(Vector2.up,v2);if(dis.x<0){angle=360-angle;};
				wp.RenewAngle(angle);

				if(!atkState)
				{
					if(atkTimer>1f/atkSpeed)
					{
						atkState=true;
						atkTimer=0f;
					}
					else atkTimer+=Game.RealDeltaTime(true);
				}
				else
				{
					float range=dis.magnitude;
					//angle=aimMove.Angle;

		
					if(wp.CheckToAtk(range,atkSpeed))
					{
						atkState=false;
					}
				}
			}
			else
			{
				angle=aimMove.Angle;

				FindNewAim();

				if(aim==null)
				if(!aimMove.move)
				{
					aimMove.v=GameHelp.Random(50,80);
					aimMove.Aim(transform.localPosition+new Vector3(Random.Range(-50,50),Random.Range(-50,50),0),true);
				}

			}

			
			if(angle>45 && angle<=135)
			{
				SwapFace(FACE.RIGHT);
			}
			else if(angle>135 && angle<=225)
			{
				SwapFace(FACE.DOWN);
			}
			else if(angle>225 && angle<=315)
			{
				SwapFace(FACE.LEFT);
			}
			else
			{
				SwapFace(FACE.UP);
			}



		}






	}
Esempio n. 5
0
	void FindNewAim()
	{
		BattleSRTM Scene=Game.SRTM<BattleSRTM>();

		int id=-1;
		float maxRange=float.MaxValue;

		for(int i=0;i< Scene.chrs.Count;i++)
		{
			CharaCtlFourFace chr =  Scene.chrs[i];
			if(chr.GetInstanceID()!=this.GetInstanceID())if(chr.living)
			{
				float range=(chr.transform.localPosition-this.transform.localPosition).magnitude;
				if(range<maxRange)
				{
					maxRange=range;
					id = i;
				}
			}

		}

		if(id!=-1)
		this.aim=Scene.chrs[id];
	}
Esempio n. 6
0
	public void Atk(CharaCtlFourFace emy)
	{
		emy.info.HP-=this.info.Atk-emy.info.Def;
	}
Esempio n. 7
0
    void Update()
    {
        if (info.HP == 0 && living)
        {
            aimMove.update = false;
            aimMove.move   = false;

            rbc.enabled = false;
            living      = false;

            GameObject go = GameObject.Instantiate(Game.EObj("DieEff")) as GameObject;

            go.transform.parent        = Game.SRTM <BattleSRTM>().charaPanel;
            go.transform.localPosition = this.transform.localPosition;
            go.transform.localScale    = Vector3.one;

            Destroy(this.gameObject);
            Game.SRTM <BattleSRTM>().chrs.Remove(this);
        }

        if (aim != null)
        {
            if (!aim.living)
            {
                aim = null;
            }
        }

        spt.depth    = -(int)transform.localPosition.y;
        wp.spt.depth = spt.depth + 1;


        if (living)
        {
            if (aim != null)
            {
                Vector3 dis    = aim.transform.localPosition - transform.localPosition;
                Vector3 aimPos = aim.transform.localPosition;

                if (wp.atkType == AtkType.Shooting)
                {
                    aimPos = dis.normalized * (dis.magnitude - wp.atkRange);
                }



                aimMove.Aim(aimPos, true);

                Vector2 v2 = new Vector2(dis.x, dis.y);
                angle = Vector2.Angle(Vector2.up, v2); if (dis.x < 0)
                {
                    angle = 360 - angle;
                }
                ;
                wp.RenewAngle(angle);

                if (!atkState)
                {
                    if (atkTimer > 1f / atkSpeed)
                    {
                        atkState = true;
                        atkTimer = 0f;
                    }
                    else
                    {
                        atkTimer += Game.RealDeltaTime(true);
                    }
                }
                else
                {
                    float range = dis.magnitude;
                    //angle=aimMove.Angle;


                    if (wp.CheckToAtk(range, atkSpeed))
                    {
                        atkState = false;
                    }
                }
            }
            else
            {
                angle = aimMove.Angle;

                FindNewAim();

                if (aim == null)
                {
                    if (!aimMove.move)
                    {
                        aimMove.v = GameHelp.Random(50, 80);
                        aimMove.Aim(transform.localPosition + new Vector3(Random.Range(-50, 50), Random.Range(-50, 50), 0), true);
                    }
                }
            }


            if (angle > 45 && angle <= 135)
            {
                SwapFace(FACE.RIGHT);
            }
            else if (angle > 135 && angle <= 225)
            {
                SwapFace(FACE.DOWN);
            }
            else if (angle > 225 && angle <= 315)
            {
                SwapFace(FACE.LEFT);
            }
            else
            {
                SwapFace(FACE.UP);
            }
        }
    }
Esempio n. 8
0
 public void Atk(CharaCtlFourFace emy)
 {
     emy.info.HP -= this.info.Atk - emy.info.Def;
 }