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; } }
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; } }
public Sprite(Texture2D texture, Vector2 iniPos, PhysicsType type) { m_texture = texture; Position = iniPos; PhysType = type; Width = texture.Width; Height = texture.Height; }
public static bool DirectLinkingType(PhysicsType pt1, PhysicsType pt2) { if (pt1 >= PhysicsType.GateNot || pt2 >= PhysicsType.GateNot) { return(false); } return(true); }
public Sprite(Texture2D texture, Vector2 iniPos, PhysicsType type) { m_texture = texture; Position = iniPos; PhysType = type; Width = texture.Width; Height = texture.Height; }
/// <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; }
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); }
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 Physics() { Mass = float.PositiveInfinity; Restitution = 0f; EntityPhysicsType = PhysicsType.KINEMATICS; EntityBoundingBoxType = BoundingBoxType.AABB; EntityImpluseType = ImpluseType.NONE; CollideeManifold = new List <CollisionManifold>(); }
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; }
//创建实例子节点 public GameObject CreateSubItem(PhysicsType type, int instanceID) { GameObject go = null; GameObject parent = GetEntityByID(instanceID); if (parent != null) { go = CreateSubItem(type, parent); } return(go); }
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); } }
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); }
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); }
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); }
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; }
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); }
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); }
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; }
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); } } } }
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); }
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); } }
//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()); }
public void SetPhysicsType(PhysicsType type) { this.status.physicsType = type; }
public PlayerObject(Vector2 position, Texture2D sprite, bool isVisible, PhysicsType type) : base(position, sprite, isVisible, type) { setDefaults(); }
public PlayerObject(int x, int y, Texture2D sprite, bool isVisible, PhysicsType type) : base(x, y, sprite, isVisible, type) { setDefaults(); }
public BlockInfo( bool isSolid, PhysicsType physics, Color32 color ) { m_isSolid = isSolid; m_physics = physics; m_color = Color; }
public GameObject(Vector2 position, Texture2D sprite, bool isVisible, PhysicsType type) { initGameObject(position, sprite, isVisible, type); }
public GameObject(int x, int y, Texture2D sprite, bool isVisible, PhysicsType type) { initGameObject(new Vector2(x, y), sprite, isVisible, type); }
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); }
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; }
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) { }
public abstract IEnumerator CreatePhysics(bool bTitled, PhysicsType pType);