Exemple #1
0
 public void BeginCast(Creature target, NVector3 pos)
 {
     this.IsCasting     = true;
     this.castTime      = 0;
     this.skillTime     = 0;
     this.cd            = this.Define.Cd;
     this.Hit           = 0;
     this.Target        = target;
     this.TargetPostion = pos;
     this.Owner.PlayAnim(this.Define.SkillAnim);
     this.Bullets.Clear();
     this.HitMap.Clear();
     if (this.Define.CastTarget == Common.Battle.TargetType.Position)
     {
         if (this.TargetPostion != null)
         {
             this.Owner.FaceTo(this.TargetPostion.ToVector3Int());
         }
     }
     else if (this.Define.CastTarget == Common.Battle.TargetType.Target)
     {
         if (this.Target != null)
         {
             this.Owner.FaceTo(this.Target.position);
         }
     }
     if (this.Define.CastTime > 0)
     {
         this.Status = SkillStatus.Casting;
     }
     else
     {
         StarSkill();
     }
 }
Exemple #2
0
        public void MPSAxisAlignedBoundingBoxTest()
        {
            var vertices = new NVector3 [3] {
                new NVector3(0.25f, 0.25f, 0.0f),
                new NVector3(0.75f, 0.25f, 0.0f),
                new NVector3(0.50f, 0.75f, 0.0f)
            };

            var vbuffer = device.CreateBuffer(vertices, MTLResourceOptions.CpuCacheModeWriteCombined);
            var indices = new uint [] { 0, 1, 2 };
            var ibuffer = device.CreateBuffer(indices, MTLResourceOptions.CpuCacheModeWriteCombined);

            var accelerationStructure = new MPSTriangleAccelerationStructure(device)
            {
                VertexBuffer  = vbuffer,
                VertexStride  = vector3Size,
                IndexBuffer   = ibuffer,
                IndexType     = MPSDataType.UInt32,
                TriangleCount = 1
            };

            accelerationStructure.Rebuild();

            var bbox = accelerationStructure.BoundingBox;

            Assert.That(bbox.Max.X, Is.EqualTo(0.75f), "bbox.Max.X");
            Assert.That(bbox.Max.Y, Is.EqualTo(0.75f), "bbox.Max.Y");
            Assert.That(bbox.Max.Z, Is.EqualTo(0.0f), "bbox.Max.Z");
            Assert.That(bbox.Min.X, Is.EqualTo(0.25f), "bbox.Min.X");
            Assert.That(bbox.Min.Y, Is.EqualTo(0.25f), "bbox.Min.Y");
            Assert.That(bbox.Min.Z, Is.EqualTo(0.0f), "bbox.Min.Z");
        }
Exemple #3
0
        public void CastSkill(int skillId, Creature target, NVector3 pos)
        {
            this.SetStandby(true);
            var skill = this.SkillMgr.GetSkill(skillId);

            skill.BeginCast(target, pos);
        }
Exemple #4
0
 public void PlayEffect(EffectType type, string name, NVector3 postion, float duration)
 {
     if (type == EffectType.Position || type == EffectType.Hit)
     {
         FXManager.Instance.PlayEffect(type, name, null, GameObjectTool.LogicToWorld(postion), duration);
     }
     else
     {
         this.EffectMgr.PlayEffect(type, name, null, GameObjectTool.LogicToWorld(postion), duration);
     }
 }
 bool PlaneSizeEqualToExtent(ARPlaneAnchor anchor, SCNPlane plane, NVector3 extent)
 {
     if (plane.Width != (nfloat)anchor.Extent.X || plane.Height != (nfloat)anchor.Extent.Z)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Exemple #6
0
 public void PlayEffect(EffectType type, string name, NVector3 position)
 {
     if (string.IsNullOrEmpty(name))
     {
         return;
     }
     if (this.Controller != null)
     {
         this.Controller.PlayEffect(type, name, position, 0);
     }
 }
Exemple #7
0
        private void Recenter()
        {
            var pos = new NVector3()
            {
                x = 0,
                y = m_HeadHeight,
                z = 0
            };

            NoloClientLib.SetHmdCenter(ref pos);
        }
Exemple #8
0
        internal Monster Creat(int spawnID, int spawnLevel, NVector3 position, NVector3 direction)
        {
            Monster monster = new Monster(spawnID, spawnLevel, position, direction);

            EntityManager.Instance.AddEntity(this.Map.ID, monster);
            monster.Id            = monster.entityId;
            monster.Info.EntityId = monster.entityId;
            monster.Info.mapId    = this.Map.ID;
            Monsters[monster.Id]  = monster;
            this.Map.MonsterEnter(monster);
            return(monster);
        }
Exemple #9
0
        internal Monster Create(int spawnMonID, int spawnLevel, NVector3 psstion, NVector3 dirtion, int spw)
        {
            Monster monster = new Monster(spawnMonID, spawnLevel, psstion, dirtion, spw);

            EntityManager.Instance.AddEntity(this.Map.ID, this.Map.InstanceId, monster);
            monster.Info.Id    = monster.entityId;
            monster.Info.mapId = this.Map.ID;
            Monsters[idx]      = monster;
            monster.MonsterId  = idx;
            idx++;
            this.Map.MonsterEnter(monster);
            return(monster);
        }
        internal DetectedPointCloud(ARPointCloud referenceObjectPointCloud, NVector3 center, NVector3 extent)
        {
            ReferenceObjectPointCloud = referenceObjectPointCloud;
            Center = center.ToSCNVector3();
            Extent = extent.ToSCNVector3();

            base.Init();

            // Semitransparently visualize the reference object's points.
            var referenceObjectPoints = new SCNNode();

            referenceObjectPoints.Geometry = PointCloud.CreateVisualization(referenceObjectPointCloud.Points, Utilities.AppYellow, 12);
            AddChildNode(referenceObjectPoints);
        }
        private void Setup(NVector3 extent)
        {
            // Translate and rotate line nodes to the correct transform
            var halfX = extent.X / 2;
            var halfY = extent.Y / 2;
            var halfZ = extent.Z / 2;

            // Two helper functions to isolate the allocations and casts
            Action <SCNNode, float, float, float> xlat = (node, extentX, extentY, extentZ) => node.LocalTranslate(new SCNVector3(extentX, extentY, extentZ));

            Action <SCNNode, float, float, float, Axis> xlatAndRot = (node, extentX, extentY, extentZ, axis) =>
            {
                xlat(node, extentX, extentY, extentZ);
                node.LocalRotate(SCNQuaternion.FromAxisAngle(axis.Normal().ToSCNVector3(), (float)-Math.PI / 2));
            };

            var halfWidth  = extent.X / 2;
            var halfHeight = extent.Y / 2;
            var halfDepth  = extent.Z / 2;

            xlatAndRot(lineNodes[0], 0, -halfHeight, -halfDepth, Axis.Z);
            xlatAndRot(lineNodes[1], -halfWidth, -halfHeight, 0, Axis.X);
            xlatAndRot(lineNodes[2], 0, -halfHeight, halfDepth, Axis.Z);
            xlatAndRot(lineNodes[3], halfWidth, -halfHeight, 0, Axis.X);
            xlat(lineNodes[4], -extent.X, 0, -halfDepth);
            xlat(lineNodes[5], -halfWidth, 0, halfDepth);
            xlat(lineNodes[6], halfWidth, 0, -halfDepth);
            xlat(lineNodes[7], halfWidth, 0, halfDepth);
            xlatAndRot(lineNodes[8], 0, halfHeight, -halfDepth, Axis.Z);
            xlatAndRot(lineNodes[9], -halfWidth, halfHeight, 0, Axis.X);
            xlatAndRot(lineNodes[10], 0, halfHeight, halfDepth, Axis.Z);
            xlatAndRot(lineNodes[11], halfWidth, halfHeight, 0, Axis.X);

            // Assign geometries
            lineNodes[0].Geometry  = Cylinder(extent.X);
            lineNodes[1].Geometry  = Cylinder(extent.Z);
            lineNodes[2].Geometry  = Cylinder(extent.X);
            lineNodes[3].Geometry  = Cylinder(extent.Z);
            lineNodes[4].Geometry  = Cylinder(extent.Y);
            lineNodes[5].Geometry  = Cylinder(extent.Y);
            lineNodes[6].Geometry  = Cylinder(extent.Y);
            lineNodes[7].Geometry  = Cylinder(extent.Y);
            lineNodes[8].Geometry  = Cylinder(extent.X);
            lineNodes[9].Geometry  = Cylinder(extent.Z);
            lineNodes[10].Geometry = Cylinder(extent.X);
            lineNodes[11].Geometry = Cylinder(extent.Z);
        }
Exemple #12
0
        private CGSize Size(NVector3 extent)
        {
            switch (face)
            {
            case PositionName.Front:
            case PositionName.Back:
                return(new CGSize(extent.X, extent.Y));

            case PositionName.Left:
            case PositionName.Right:
                return(new CGSize(extent.Z, extent.Y));

            case PositionName.Bottom:
            case PositionName.Top:
                return(new CGSize(extent.X, extent.Z));
            }
            throw new Exception("Somehow fell through switch statement that should be exhaustive.");
        }
Exemple #13
0
        internal void SendSkillCast(int skillId, int casterId, int targetId, NVector3 position)
        {
            if (position == null)
            {
                position = new NVector3();
            }
            Debug.LogFormat("SendSkillCast: skill :{0} caster:{1} target:{2} pos:{3}", skillId, casterId, targetId, position.String());
            NetMessage message = new NetMessage();

            message.Request                             = new NetMessageRequest();
            message.Request.skillCast                   = new SkillCastRequest();
            message.Request.skillCast.castInfo          = new NSkillCastInfo();
            message.Request.skillCast.castInfo.skillId  = skillId;
            message.Request.skillCast.castInfo.casterId = casterId;
            message.Request.skillCast.castInfo.targetId = targetId;
            message.Request.skillCast.castInfo.Position = position;
            NetClient.Instance.SendMessage(message);
        }
Exemple #14
0
    public Nolo_Transform(NVector3 pos, NQuaternion rot, NVector3 vecVelocity, NVector3 vecAngularVelocity)
    {
        this.pos.x = pos.x;
        this.pos.y = pos.y;
        this.pos.z = pos.z;

        this.rot.w = rot.w;
        this.rot.x = rot.x;
        this.rot.y = rot.y;
        this.rot.z = rot.z;

        this.vecVelocity.x = vecVelocity.x;
        this.vecVelocity.y = vecVelocity.y;
        this.vecVelocity.z = -vecVelocity.z;

        this.vecAngularVelocity.x = vecAngularVelocity.x;
        this.vecAngularVelocity.y = vecAngularVelocity.y;
        this.vecAngularVelocity.z = vecAngularVelocity.z;
    }
        internal Wireframe(NVector3 extent, UIColor color, double scale = 1.0)
        {
            base.Init();

            this.color     = color;
            lineThickness *= scale;

            // Repeat 12x
            for (int i = 1; i <= 12; i++)
            {
                var line = new SCNNode();
                lineNodes.Add(line);
                AddChildNode(line);
            }

            Setup(extent);

            NSNotificationCenter.DefaultCenter.AddObserver(ObjectOrigin.MovedOutsideBoxNotificiationName, Flash);
        }
Exemple #16
0
        internal void UpdateBoundingBoxExtent(NVector3 extent)
        {
            switch (face)
            {
            case PositionName.Front:
                Position = new SCNVector3(0, 0, extent.Z / 2);
                break;

            case PositionName.Back:
                Position = new SCNVector3(0, 0, -extent.Z / 2);
                break;

            case PositionName.Left:
                Position = new SCNVector3(-extent.X / 2, 0, 0);
                break;

            case PositionName.Right:
                Position = new SCNVector3(extent.X / 2, 0, 0);
                break;

            case PositionName.Bottom:
                Position = new SCNVector3(0, -extent.Y / 2, 0);
                break;

            case PositionName.Top:
                Position = new SCNVector3(0, extent.Y / 2, 0);
                break;
            }

            // Update extensions if the size has changed.
            var newSize = Size(extent);

            if (newSize != size)
            {
                size = newSize;
                UpdateExtensions();
            }
        }
Exemple #17
0
    public static bool EntityUpdate(NEntity nEntity, Vector3 position, Quaternion rotation, float speed)
    {
        NVector3 nPossition = WorldToLogicN(position);
        NVector3 nDirection = WorldToLogicN(rotation.eulerAngles);
        int      _speed     = WorldToLogic(speed);
        bool     updated    = false;

        if (!nEntity.Position.Equal(nPossition))
        {
            nEntity.Position = nPossition;
            updated          = true;
        }
        if (!nEntity.Direction.Equal(nDirection))
        {
            nEntity.Direction = nDirection;
            updated           = true;
        }
        if (nEntity.Speed != _speed)
        {
            nEntity.Speed = _speed;
            updated       = true;
        }
        return(updated);
    }
Exemple #18
0
    public static bool EntityUpdate(NEntity entity, UnityEngine.Vector3 position, Quaternion rotation, float speed)
    {
        NVector3 pos     = WorldToLogicN(position);
        NVector3 dir     = WorldToLogicN(rotation.eulerAngles);
        int      spd     = WorldToLogic(speed);
        bool     updated = false;

        if (!entity.Position.Equal(pos))
        {
            entity.Position = pos;
            updated         = true;
        }
        if (!entity.Direction.Equal(dir))
        {
            entity.Direction = dir;
            updated          = true;
        }
        if (entity.Speed != spd)
        {
            entity.Speed = spd;
            updated      = true;
        }
        return(updated);
    }
        public static bool EntityUpdata(NEntity entity, Vector3 position, Quaternion rotation, float speed)
        {
            NVector3 pos    = WorldToLogicN(position);
            NVector3 dir    = WorldToLogicN(rotation.eulerAngles);
            int      sped   = Mathf.RoundToInt(speed);
            bool     updata = false;

            if (!entity.Position.Equal(pos))//是否一样
            {
                entity.Position = pos;
                updata          = true;
            }
            if (!entity.Direction.Equal(dir))
            {
                entity.Direction = dir;
                updata           = true;
            }
            if (entity.Speed != sped)
            {
                entity.Speed = sped;
                updata       = true;
            }
            return(updata);
        }
 internal static NVector3 Times(this NVector3 self, float scale)
 {
     return(new NVector3(self.X * scale, self.Y * scale, self.Z * scale));
 }
 // Euclidean norm
 internal static float Length(this NVector3 self)
 {
     return((float)Sqrt(self.X * self.X + self.Y * self.Y + self.Z * self.Z));
 }
 internal static NVector3 Plus(this NVector3 self, NVector3 other) => new NVector3(self.X + other.X, self.Y + other.Y, self.Z + other.Z);
 internal static NVector3 Minus(this NVector3 self, NVector3 other)
 {
     return(new NVector3(self.X - other.X, self.Y - other.Y, self.Z - other.Z));
 }
        internal static float Distance(this NVector3 self, NVector3 other)
        {
            var distanceSquared = Pow(self.X - other.X, 2) + Pow(self.Y - other.Y, 2) + Pow(self.Z - other.Z, 2);

            return((float)Sqrt(distanceSquared));
        }
Exemple #25
0
 public static Vector3 LogicToWorld(NVector3 vector)
 {
     return(new Vector3(vector.X / UNIT_MULTIPLE, vector.Z / UNIT_MULTIPLE, vector.Y / UNIT_MULTIPLE));
 }
 internal static NVector3 Minus(this SCNVector3 self, NVector3 other) => new NVector3(self.X - other.X, self.Y - other.Y, self.Z - other.Z);
 // Element-wise maximum
 internal static NVector3 Max(this NVector3 self, NVector3 other)
 {
     return(new NVector3(Math.Max(self.X, other.X), Math.Max(self.Y, other.Y), Math.Max(self.Y, other.Y)));
 }
Exemple #28
0
 public static Vector3 LogicToWorld(NVector3 vector)
 {
     return(new Vector3(vector.X / 100f, vector.Z / 100f, vector.Y / 100f));
 }
 internal static SCNVector3 ToSCNVector3(this NVector3 self) => new SCNVector3(self.X, self.Y, self.Z);
Exemple #30
0
 internal PlaneDrag(NMatrix4 planeTransform, NVector3 offset)
 {
     this.PlaneTransform = planeTransform;
     this.Offset         = offset;
 }