Ejemplo n.º 1
0
    void AddPrimitiveData(EntityData entity, PhysicsType type, GameObject go)
    {
        switch (type)
        {
        case PhysicsType.Cube:
            CubeData cube = new CubeData();
            cube.posX = Round(go.transform.localPosition.x);
            cube.posY = Round(go.transform.localPosition.y);
            cube.posZ = Round(go.transform.localPosition.z);

            cube.quaternionX = Round(go.transform.localRotation.x);
            cube.quaternionY = Round(go.transform.localRotation.y);
            cube.quaternionZ = Round(go.transform.localRotation.z);
            cube.quaternionW = Round(go.transform.localRotation.w);

            cube.length = Round(go.transform.localScale.x);
            cube.height = Round(go.transform.localScale.y);
            cube.width  = Round(go.transform.localScale.z);

            entity.cubeData.Add(cube);
            break;

        case PhysicsType.Sphere:
            SphereData sphere = new SphereData();
            sphere.posX = Round(go.transform.localPosition.x);
            sphere.posY = Round(go.transform.localPosition.y);
            sphere.posZ = Round(go.transform.localPosition.z);

            sphere.radius = Round(go.transform.localScale.x / 2);

            entity.sphereData.Add(sphere);
            break;
        }
    }
Ejemplo n.º 2
0
        private void UpdateVolume()
        {
            PhysicsType type = GetPhysicsType();
            Vector3 scale = Scale;

            switch (type)
            {
                case PhysicsType.Box:
                    m_volume = scale.X * scale.Y * scale.Z;
                    break;
                case PhysicsType.Sphere:
                    m_volume = 4.1887902f * scale.X * scale.Y * scale.Z;
                    break;
                case PhysicsType.Cylinder:
                    m_volume = Utils.PI * scale.X * scale.Y * scale.Z;
                    break;
                case PhysicsType.ConvexHull:
                    ConvexHullSet hullSet = m_mesher.GetConvexHulls(this);
                    if (hullSet != null)
                        m_volume = hullSet.Volume;
                    else
                        m_volume = scale.X * scale.Y * Scale.Z;
                    break;
                default:
                    m_log.Warn("LLPrimitive has an unhandled physics proxy type: " + type);
                    m_volume = scale.X * scale.Y * scale.Z;
                    break;
            }
        }
Ejemplo n.º 3
0
 public Sprite(Texture2D texture, Vector2 iniPos, PhysicsType type)
 {
     m_texture = texture;
     Position  = iniPos;
     PhysType  = type;
     Width     = texture.Width;
     Height    = texture.Height;
 }
Ejemplo n.º 4
0
 public static bool DirectLinkingType(PhysicsType pt1, PhysicsType pt2)
 {
     if (pt1 >= PhysicsType.GateNot || pt2 >= PhysicsType.GateNot)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 5
0
 public Sprite(Texture2D texture, Vector2 iniPos, PhysicsType type)
 {
     m_texture = texture;
     Position = iniPos;
     PhysType = type;
     Width = texture.Width;
     Height = texture.Height;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes the wrapper for 2D collisions.
        /// </summary>
        /// <param name="collision2D">The source Collision2D object.</param>
        public ImpactCollisionWrapper(Collision2D collision2D)
        {
            source2D = collision2D;
            source3D = null;

            ContactCount = collision2D.contactCount;

            PhysicsType = PhysicsType.Physics2D;
        }
Ejemplo n.º 7
0
 public Sprite(Texture2D texture, Vector2 iniPos, PhysicsType type, bool _isNonStop)
 {
     m_texture = texture;
     Position  = iniPos;
     PhysType  = type;
     IsNonStop = _isNonStop;
     Width     = texture.Width;
     Height    = texture.Height;
 }
        public PhysicsComponent(int width, int height, PhysicsType type)
        {
            gravityScale = 1.0;
            velocity = Vector2.Zero;
            hitBox = new Hitbox(width, height);
            this.type = type;

            //PhysicsSystem.Instance.addComponent(this);
        }
Ejemplo n.º 9
0
 public Sprite(Texture2D texture, Vector2 iniPos, PhysicsType type, bool _isNonStop)
 {
     m_texture = texture;
     Position = iniPos;
     PhysType = type;
     IsNonStop = _isNonStop;
     Width = texture.Width;
     Height = texture.Height;
 }
Ejemplo n.º 10
0
 public Physics()
 {
     Mass                  = float.PositiveInfinity;
     Restitution           = 0f;
     EntityPhysicsType     = PhysicsType.KINEMATICS;
     EntityBoundingBoxType = BoundingBoxType.AABB;
     EntityImpluseType     = ImpluseType.NONE;
     CollideeManifold      = new List <CollisionManifold>();
 }
Ejemplo n.º 11
0
        internal EntityLocation Velocity;         //Were just using this to hold the three dimensional velocity vector

        internal Physics(EntityLocation location, Entity owner, PhysicsType type)
        {
            Owner = owner;
            PType = type;

            Velocity    = new EntityLocation(owner.world);
            Location    = location;
            OldLocation = location;
        }
Ejemplo n.º 12
0
    //创建实例子节点
    public GameObject CreateSubItem(PhysicsType type, int instanceID)
    {
        GameObject go = null;

        GameObject parent = GetEntityByID(instanceID);

        if (parent != null)
        {
            go = CreateSubItem(type, parent);
        }

        return(go);
    }
Ejemplo n.º 13
0
        private void ProcessPhsysicsType(GameObject target, PhysicsType type)
        {
            if (type == PhysicsType.BounceAll)
            {
                IList <ComponentDefaultEffect> effects = gameObject.GetComponents <ComponentDefaultEffect>();

                for (int index = 0; index < effects.Count; index++)
                {
                    Destroy(effects[index]);
                }

                Collider2D[] colliders = target.GetComponents <Collider2D>();

                for (int index = 0; index < colliders.Length; index++)
                {
                    Physics2D.IgnoreCollision(GetComponent <Collider2D>(), colliders[index]);
                }

                gameObject.AddComponent <ComponentDefaultEffect>().spinEnabled = false;
            }
            else if (type == PhysicsType.BounceOne)
            {
                IList <ComponentDefaultEffect> effects = gameObject.GetComponents <ComponentDefaultEffect>();

                for (int index = 0; index < effects.Count; index++)
                {
                    Destroy(effects[index]);
                }

                collider2D.enabled = false;

                gameObject.AddComponent <ComponentDefaultEffect>().spinEnabled = false;
            }
            else if (type == PhysicsType.PenetrationAll)
            {
                Collider2D[] colliders = target.GetComponents <Collider2D>();

                for (int index = 0; index < colliders.Length; index++)
                {
                    Physics2D.IgnoreCollision(GetComponent <Collider2D>(), colliders[index]);
                }

                body2D.velocity = velocity;
            }
            else
            {
                Destroy(this.gameObject);
            }
        }
Ejemplo n.º 14
0
        public bool LevelUP()
        {
            if (LevelMax())
            {
                return(false);
            }

            DisassemblygirlWeaponConfig config = ConfigMgr.GetInstance().DisassemblygirlWeapon.GetConfigById(id + 1);

            id     = config.id;
            level  = config.level;
            name   = config.name;
            iconID = config.iconID;

            attributeBox.SetAttribute(AttributeKeys.ATK, AttributeSetTypes.BaseValue, config.ATK);
            attributeBox.SetAttribute(AttributeKeys.CRT, AttributeSetTypes.BaseValue, config.CRT);
            attributeBox.SetAttribute(AttributeKeys.SPD, AttributeSetTypes.BaseValue, config.SPD);

            WOE = config.WOE;
            GP  = config.GP;
            RP  = config.RP;
            CD  = config.CD;

            resourceID  = config.resourceID;
            hitEffectID = config.hitEffectID;
            audioID     = config.audioID;

            offsetX     = config.offsetX;
            offsetY     = config.offsetY;
            physicsType = (PhysicsType)config.physicsType;

            if (config.skillID != 0)
            {
                skillData = SkillData.FromConfig(config.skillID);
            }

            effectors.Clear();

            foreach (string effectorID in config.effectors.Split('|'))
            {
                EffectorData effector = EffectorData.FromConfig(int.Parse(effectorID));

                if (effector != null)
                {
                    effectors.Add(effector);
                }
            }
            return(true);
        }
Ejemplo n.º 15
0
 RigidbodyType2D getBodyType(PhysicsType pt)
 {
     if (pt == PhysicsType.Dynamic)
     {
         return(RigidbodyType2D.Dynamic);
     }
     else if (pt == PhysicsType.Static)
     {
         return(RigidbodyType2D.Static);
     }
     else if (pt == PhysicsType.Kinematic)
     {
         return(RigidbodyType2D.Kinematic);
     }
     return(RigidbodyType2D.Dynamic);
 }
Ejemplo n.º 16
0
        public bool PhysicsConnects(int type1, int type2)
        {
            PhysicsType t1 = (PhysicsType)type1;
            PhysicsType t2 = (PhysicsType)type2;

            if (t1 >= PhysicsType.Circuit &&
                t2 >= PhysicsType.Circuit
                //              && t1 < PhysicsType.GateNot
//                && t2 < PhysicsType.GateNot
                )
            {
                //Normal circuit
                return(true);
            }

            return(false);
        }
Ejemplo n.º 17
0
        public void SetCollider(PhysicsType type)
        {
            if (PhysicsBodyInitialized)
            {
                RemoveCollider();

                if (type == PhysicsType.None)
                {
                    PhysicsType = type;
                    if (Physics.PhysicsObjects.Contains(this))
                    {
                        Physics.PhysicsObjects.Remove(this);
                    }

                    return;
                }
            }

            if (type == PhysicsType.Cube)
            {
                Box shape = new Box(2.0f, 2.0f, 2.0f);
                ShapeIndex = Physics.simulator.Shapes.Add(shape);
                Shape      = shape;
            }
            else if (type == PhysicsType.Sphere)
            {
                Sphere shape = new Sphere(2.0f);
                ShapeIndex = Physics.simulator.Shapes.Add(shape);
                Shape      = shape;
            }

            Shape.ComputeInertia(Mass, out BodyInertia inertia);

            PhysicsDescription = BodyDescription.CreateDynamic(transform.Position, inertia, new CollidableDescription(ShapeIndex, 0.1f), new BodyActivityDescription(0.01f));
            BodyHandle         = Physics.simulator.Bodies.Add(PhysicsDescription);
            BodyReference      = Physics.simulator.Bodies.GetBodyReference(BodyHandle);

            if (!Physics.PhysicsObjects.Contains(this))
            {
                Physics.PhysicsObjects.Add(this);
            }

            PhysicsType            = type;
            PhysicsBodyInitialized = true;
            physicsEnabled         = true;
        }
Ejemplo n.º 18
0
        private static bool CanBeHit(HitDef hitDef, HitBy hitBy, NoHitBy noHitBy, PhysicsType defenderPhysicsType)
        {
            if (hitBy != null && !hitBy.Check(hitDef))
            {
                return(false);
            }
            if (noHitBy != null && noHitBy.Check(hitDef))
            {
                return(false);
            }
            int hitFlag = hitDef.hitFlag;

            if ((hitFlag & (int)HitFlag.H) != 0)
            {
                if (defenderPhysicsType == PhysicsType.Stand)
                {
                    return(true);
                }
            }
            if ((hitFlag & (int)HitFlag.L) != 0)
            {
                if (defenderPhysicsType == PhysicsType.Crouch)
                {
                    return(true);
                }
            }

            /*
             * if ((hitFlag & (int)HitFlag.A) != 0)
             * {
             *  if (defenderPhysicsType == PhysicsType.Air && (this.fsmMgr.stateNo != 5050))
             *      return true;
             * }
             * if ((hitFlag & (int)HitFlag.F) != 0)
             * {
             *  if (defenderPhysicsType == PhysicsType.Air && (fsmMgr.stateNo == 5050))
             *      return true;
             * }
             * if ((hitFlag & (int)HitFlag.D) != 0)
             * {
             * }
             */
            return(false);
        }
Ejemplo n.º 19
0
        private static bool CanBeGuard(HitDef hitDef, PhysicsType defenderPhysicsType)
        {
            int guardFlag = hitDef.guardFlag;

            if ((guardFlag & (int)GuardFlag.H) != 0)
            {
                if (defenderPhysicsType == PhysicsType.Stand)
                {
                    return(true);
                }
            }
            if ((guardFlag & (int)GuardFlag.L) != 0)
            {
                if (defenderPhysicsType == PhysicsType.Crouch)
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 20
0
        public CCPhysicsShape()
        {
            _body               = null;
            _info               = null;
            _type               = PhysicsType.UNKNOWN;
            _area               = 0;
            _mass               = CCPhysicsBody.MASS_DEFAULT;
            _moment             = CCPhysicsBody.MOMENT_DEFAULT;
            _tag                = 0;
            _categoryBitmask    = int.MaxValue;
            _collisionBitmask   = int.MaxValue;
            _contactTestBitmask = 0;
            _group              = 0;

            _info = new CCPhysicsShapeInfo(this);

            _scaleX    = 1.0f;
            _scaleY    = 1.0f;
            _newScaleX = 1.0f;
            _newScaleY = 1.0f;
            _dirty     = false;
        }
Ejemplo n.º 21
0
        public static IEnumerator CreateAllRoomPlayer()
        {
            List <IEnumerator> createlist = new List <IEnumerator>();

            int listCount = mDancerList.Count;

            for (int i = 0; i < listCount; ++i)
            {
                RoomPlayerData dancerData = mDancerList[i];
                if (dancerData != null && dancerData.mRoomPlayer != null)
                {
                    int dancerPos = dancerData.mRoomPlayer.RolePos;
                    if (dancerData.mRoomPlayer != mMeInfo)
                    {
                        PlayerBase dancerPlayer = mRoomPlayer[dancerPos];
                        if (dancerPlayer != null)
                        {
                            PhysicsType pType = PhysicsType.Player;

                            IEnumerator itor = dancerPlayer.CreatePhysics(true, pType);
                            createlist.Add(itor);
                        }
                    }
                }
            }

            while (createlist.Count != 0)
            {
                yield return(null);

                for (int i = 0; i < createlist.Count; ++i)
                {
                    if (!createlist[i].MoveNext())
                    {
                        createlist.RemoveAt(i);
                    }
                }
            }
        }
Ejemplo n.º 22
0
    public GameObject CreateSubItem(PhysicsType type, GameObject parent)
    {
        GameObject go;

        switch (type)
        {
        case PhysicsType.Cube:
            go     = GameObject.CreatePrimitive(PrimitiveType.Cube);
            go.tag = type.ToString();
            break;

        case PhysicsType.Sphere:
            go     = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            go.tag = type.ToString();
            break;

        default:
            Debug.LogError("can not find the type:" + type);
            return(null);
        }
        go.transform.SetParent(parent.transform);
        return(go);
    }
Ejemplo n.º 23
0
        private void initGameObject(Vector2 position, Texture2D sprite, bool isVisible, PhysicsType type)
        {
            //this.position = position;
            this.position = position;
            this.drawSpace = new Rectangle(position.ToPoint().X, position.ToPoint().Y, sprite.Width, sprite.Height);
            this.isVisible = isVisible;

            this.rendComp = new RenderComponent(sprite);

            if(type != PhysicsType.MechanicsObject)
            {
                this.physComp = new PhysicsComponent(sprite.Width, sprite.Height, type);

                if (type == PhysicsType.StaticObject)
                    PhysicsSystem.Instance.addStaticObject(this.physComp);
                else if (type == PhysicsType.Door)
                    PhysicsSystem.Instance.addDoorObject(this.physComp);
                else if (type == PhysicsType.Player) { }
                else
                    throw new NotSupportedException("The type [" + type.ToString() + "] is not supported by the Physics System yet");

                this.physComp.UpdateHitBoxPosition(position);
            }
        }
Ejemplo n.º 24
0
        //For Rectangles
        //TranslationOffset



        //Offset system
        // Create rectangles, then adjust them with offsets. This would allow rings within rings
        //Byte 1: X offset : signed -127 to 127
        //Byte 2: Y offset : signed -127 to 127
        //Byte 3: Z offset : signed -127 to 127
        //Byte 4: ???
        //public ulong Offsets { get; set; }

        //Neighbor system
        //Greate adjacency matrix of all rectangles
        // Then create circuit paths to represent what touches
        // Then allow power up/energizing of those paths

        public static string GetPhysicsDescription(PhysicsType pt)
        {
            return(pt.ToString());
        }
Ejemplo n.º 25
0
 public void SetPhysicsType(PhysicsType type)
 {
     this.status.physicsType = type;
 }
Ejemplo n.º 26
0
 public PlayerObject(Vector2 position, Texture2D sprite, bool isVisible, PhysicsType type)
     : base(position, sprite, isVisible, type)
 {
     setDefaults();
 }
Ejemplo n.º 27
0
 public PlayerObject(int x, int y, Texture2D sprite, bool isVisible, PhysicsType type)
     : base(x, y, sprite, isVisible, type)
 {
     setDefaults();
 }
Ejemplo n.º 28
0
 public BlockInfo( bool isSolid, PhysicsType physics, Color32 color )
 {
     m_isSolid = isSolid;
     m_physics = physics;
     m_color = Color;
 }
Ejemplo n.º 29
0
 public GameObject(Vector2 position, Texture2D sprite, bool isVisible, PhysicsType type)
 {
     initGameObject(position, sprite, isVisible, type);
 }
Ejemplo n.º 30
0
 public GameObject(int x, int y, Texture2D sprite, bool isVisible, PhysicsType type)
 {
     initGameObject(new Vector2(x, y), sprite, isVisible, type);
 }
Ejemplo n.º 31
0
        public DamageInfo Create(Character character, int weaponIndex, Vector3 charPosition, InfInt damage, DamageType damageType, Vector3 targetPos, WeaponTag weaponTag, PhysicsType physics = PhysicsType.None, DotItem dot = null, DamageModifier modifier = DamageModifier.None, ZombieFX hitFx = ZombieFX.Unknown, ZombieFX dieFx = ZombieFX.Unknown)
        {
            DamageInfo info = Create();

            info.Character             = character;
            info.WeaponIndex           = weaponIndex;
            info.CharPosition          = charPosition;
            info.Damage                = new InfInt(damage);
            info.DamageType            = damageType;
            info.TargetPosition        = targetPos;
            info.ExplosionSphereRadius = 0.0f;
            info.Dot      = dot;
            info.Physics  = physics;
            info.Tags     = weaponTag;
            info.Modifier = modifier;
            info.HitFX    = hitFx;
            info.DieFX    = dieFx;
            return(info);
        }
Ejemplo n.º 32
0
		public CCPhysicsShape()
		{
			_body = null;
			_info = null;
			_type = PhysicsType.UNKNOWN;
			_area = 0;
			_mass = CCPhysicsBody.MASS_DEFAULT;
			_moment = CCPhysicsBody.MOMENT_DEFAULT;
			_tag = 0;
			_categoryBitmask = int.MaxValue;
			_collisionBitmask = int.MaxValue;
			_contactTestBitmask = 0;
			_group = 0;

			_info = new CCPhysicsShapeInfo(this);

			_scaleX = 1.0f;
			_scaleY = 1.0f;
			_newScaleX = 1.0f;
			_newScaleY = 1.0f;
			_dirty = false;

		}
Ejemplo n.º 33
0
 public PhysicsComponent(Mesh mesh, PhysicsType physics, MotionType motion) : base(mesh)
 {
     Physics = physics;
     Type    = ComponentType.Physics;
     Motion  = motion;
 }
 public MechanicsBaseComponent(int width, int height, PhysicsType type)
     : base(width, height, type)
 {
 }
Ejemplo n.º 35
0
 public abstract IEnumerator CreatePhysics(bool bTitled, PhysicsType pType);