Example #1
0
 public CMove(CThucHanh pThucHanh, string pName, CActObj pObj, int start, int pduration, List <Vector3> ptargets, bool pstophide, float pdstopangleZ, int pisound, bool loop) : base(pThucHanh)
 {
     this.Name           = pName;
     this.Obj            = pObj;
     this.StartTickCount = start;
     this.duration       = pduration;
     this.StopTickCount  = this.StartTickCount + this.duration;
     this.stophide       = pstophide;
     this.stopangleZ     = Geometry.DegreeToRadian(pdstopangleZ);
     this.targets        = new List <CTarget>();
     foreach (Vector3 current in ptargets)
     {
         CTarget cTarget = new CTarget();
         cTarget.Position = current;
         if (cTarget.Position.Z == 0f)
         {
             cTarget.Position.Z = this.myThucHanh.myTerrain.getZ(current.X, current.Y);
         }
         this.targets.Add(cTarget);
     }
     this.targetsCount = this.targets.Count;
     this.SetTickCount();
     this.itarget   = 0;
     this.done      = false;
     this.isound    = pisound;
     this.soundloop = loop;
 }
 public CShootFrom(CThucHanh pThucHanh, string pName, string texfile, float pWidth, float pHeight, int start, int pduration, float pspeed, CActObj pFromObj, Vector3 pTo, int pisound, bool loop) : base(pThucHanh)
 {
     this.Name      = pName;
     this.fromObj   = pFromObj;
     this.SpriteObj = this.myThucHanh.Add1SpriteObj(texfile, pWidth, pHeight, 0, this.fromObj.Position, 0f);
     this.topos     = pTo;
     if (pTo.Z == 0f)
     {
         this.topos.Z = this.myThucHanh.myTerrain.getZ(this.topos.X, this.topos.Y) - 0.2f;
     }
     this.StartTickCount = start;
     this.duration       = pduration;
     this.speed          = pspeed;
     this.tickcount      = (int)(this.speed * 1000f);
     this.StopTickCount  = this.StartTickCount + this.duration;
     this.from2          = new CTarget();
     this.to2            = new CTarget();
     this.isound         = pisound;
     this.soundloop      = loop;
 }
        protected virtual void Calc2()
        {
            this.setfrompos();
            float z = this.myThucHanh.myTerrain.getZ(this.from2.Position.X, this.from2.Position.Y);

            if (this.from2.Position.Z == 0f)
            {
                this.from2.Position.Z = z;
            }
            if (this.from2.Position.Z >= z)
            {
                CTarget expr_7D_cp_0 = this.from2;
                expr_7D_cp_0.Position.Z = expr_7D_cp_0.Position.Z - 0.4f;
            }
            this.from2.TickCount = this.to2.TickCount;
            Vector3 addvector = this.to2.Position - this.from2.Position;

            this.to2.TickCount   += this.tickcount;
            this.SpriteObj.angleZ = CAct.GetAngleZ(addvector);
            this.SpriteObj.angleX = CAct.GetAngleX(addvector);
        }
Example #4
0
 public CShoot(CThucHanh pThucHanh, string pName, string texfile, float pWidth, float pHeight, int start, int pduration, float pspeed, Vector3 pFromPos, Vector3 pTo, int pisound, bool loop) : base(pThucHanh)
 {
     this.Name      = pName;
     this.frompos   = pFromPos;
     this.SpriteObj = this.myThucHanh.Add1SpriteObj(texfile, pWidth, pHeight, 0, this.frompos, 0f);
     this.origtopos = pTo;
     if (this.origtopos.Z == 0f & this.frompos.Z == 0f)
     {
         this.NeedShiftZ = true;
     }
     if (this.origtopos.Z == 0f)
     {
         this.origtopos.Z = this.myThucHanh.myTerrain.getZ(this.origtopos.X, this.origtopos.Y);
     }
     this.StartTickCount = start;
     this.duration       = pduration;
     this.speed          = pspeed;
     this.StopTickCount  = this.StartTickCount + this.duration;
     this.from2          = new CTarget();
     this.to2            = new CTarget();
     this.Calc2();
     this.isound    = pisound;
     this.soundloop = loop;
 }
        private void GetOrbit(Vector3 pFrom, Vector3 pTo)
        {
            Vector3 right  = new Vector3(this.frompos.X, this.frompos.Y, this.topos.Z);
            Vector3 vector = this.topos - right;
            float   num    = vector.Length();
            float   angleZ = CAct.GetAngleZ(vector);

            vector.Z = (float)Math.Tan((double)this.rAngle) * num;
            int num2 = (int)(this.topos - this.frompos).Length();

            this.targets = new List <CTarget>();
            double num3   = (double)(vector.Z - (pTo.Z - pFrom.Z));
            float  valueZ = 0f;

            if (num2 > 0)
            {
                valueZ = -(float)(num3 * 2.0 / (double)(num2 * (num2 + 1)));
            }
            Vector3 vector2 = vector * (1f / (float)num2);
            Vector3 right2  = new Vector3(0f, 0f, valueZ);
            Vector3 vector3 = pFrom;
            CTarget cTarget = new CTarget();

            cTarget.Position  = vector3;
            cTarget.TickCount = 0;
            cTarget.angleZ    = angleZ;
            cTarget.angleX    = CAct.GetAngleX(vector2);
            this.targets.Add(cTarget);
            if (num2 > 1)
            {
                float num4 = 0f;
                for (int i = 1; i < num2; i++)
                {
                    vector2         += right2;
                    vector3         += vector2;
                    cTarget          = new CTarget();
                    cTarget.Position = vector3;
                    cTarget.angleZ   = angleZ;
                    cTarget.angleX   = CAct.GetAngleX(vector2);
                    this.targets.Add(cTarget);
                    this.targets[i].len = (this.targets[i].Position - this.targets[i - 1].Position).Length();
                    num4 += this.targets[i].len;
                }
                this.targetsCount = num2;
                float num5 = 0f;
                for (int j = 1; j < this.targetsCount; j++)
                {
                    num5 += this.targets[j].len;
                    if (num4 > 0f)
                    {
                        this.targets[j].TickCount = (int)(num5 * (float)this.interval / num4);
                    }
                    else
                    {
                        this.targets[j].TickCount = this.interval;
                    }
                }
                return;
            }
            cTarget           = new CTarget();
            cTarget.Position  = this.topos;
            cTarget.TickCount = 0;
            cTarget.angleZ    = angleZ;
            cTarget.angleX    = CAct.GetAngleX(vector2);
            this.targets.Add(cTarget);
        }