public override void collide(object sender, CActor collider) { if (!Map.CMapManager.mapSwapIssued) { CMasterControl.mapManager.swapMap(_mapName, "player", _playerPosition, Map.CMapManager.TRANSITION_FADE_TO_BLACK); } }
public override void collide(object sender, CActor collider) { if (collider is Items.shields.CBaseShield) { _killMe = true; } }
public override void collide(object sender, CActor collider) { if (collider is Actors.Collision.CSolidTile) { _changeDirection(); solidCollide(collider); } else if (collider is Actors.Projectiles.CBomb && collider.state == ACTOR_STATES.EXPLODE) { _killMe = true; } else if (collider is Items.Swords.CSword) { _killMe = true; } else if (collider is Player.CPlayer) { if (_state == ACTOR_STATES.MOVING) { _state = ACTOR_STATES.HOLD; collider.stun(-1); _loseShieldTimer = 0; _actorToHug = collider; _actorToHug.state = ACTOR_STATES.INVISIBLE; startTimer2(60); } } }
public CHitBox(CActor actor, float offsetx, float offsety, float width, float height) { _halfSize = new Vector2(width * .5f, height * .5f); _center = new Vector2(offsetx + _halfSize.X, offsety + _halfSize.Y); this.actor = actor; _topLeftAngle = MathExt.MathExt.angle(_center, offset); _topRightAngle = MathExt.MathExt.angle(_center, new Vector2(offset.X + halfWidth * 2, offset.Y)); _bottomLeftAngle = _topRightAngle + 180; _bottomRightAngle = _topLeftAngle + 180; _topLeft = new Vector2(_center.X - _halfSize.X, _center.Y - _halfSize.Y); _topRight = new Vector2(_center.X + _halfSize.X, _center.Y - _halfSize.Y); _bottomLeft = new Vector2(_center.X - _halfSize.X, _center.Y + _halfSize.Y); _bottomRight = new Vector2(_center.X + _halfSize.X, _center.Y + _halfSize.Y); //Prepare texture for rendering hitbox when needed(Only done for the first hitbox, as they share the texture) if (texture == null) { //Make a single pixel with transparency that we later stretch to the size of our hitbox texture = new Texture2D(CGraphics.GPU, 1, 1, false, SurfaceFormat.Color); Color[] c = new Color[1]; c[0] = Color.FromNonPremultiplied(255, 0, 0, 200); texture.SetData <Color>(c); } }
public override void collide(object sender, CActor collider) { if (collider is Player.CPlayer) { collider.dealDamange(2, collider); } if (collider is Items.Swords.CSword && !_isReal) { collider.shock(); } if (collider is Projectiles.CArrow) { _wasStruckByArrow = true; if (!_isReal) { _removeCurrentPosition(true); Items.Drops.CArrowDrop arrow = new Items.Drops.CArrowDrop(); arrow.init(_name + "_arrowDrop" + Collision.CHitBox.produceRandomName(), _position, "", this.componentAddress); arrow.layer = this.layer; Map.CMapManager.addActorToComponent(arrow, this.componentAddress); } collider.killMe = true; _arrowResponse(); } }
public override void collide(object sender, CActor collider) { if (_state != "Lift" && collider is CSolidTile) { solidCollide(collider); } }
public override void collide(object sender, CActor collider) { if (collider is Projectiles.CBomb) { if (collider.state == ACTOR_STATES.EXPLODE) { if (_hasShell) { _hasShell = false; swapImage(_WALK_NOSHELL); _invulernable = true; startTimer1(200); } else if (!_invulernable) { _killMe = true; } } } if (!_hasShell && !_invulernable) { if (collider is Projectiles.CProjectile) { _killMe = true; } } }
public override void collide(object sender, CActor collider) { base.collide(sender, collider); if (collider is Collision.CSolidTile) { solidCollide(collider); } }
void Start() { m_Actor = new CActor(); m_Client = new Net.Tcp.TcpClient(m_Actor); m_Client.Start(); Tools.GetComponent <Tools>().SendJoinGameReq(); DontDestroyOnLoad(gameObject); }
public override void collide(object sender, CActor collider) { if (_state != ACTOR_STATES.INVISIBLE) { base.collide(sender, collider); _yieldToPlayer(); } }
public override void collide(object sender, CActor collider) { if (collider is Projectiles.CFireBall) { _killMe = true; Graphics.CEffects.createEffect(Graphics.CTextures.EFFECT_FIRE_BALL_SMALL, _position, 9); CMasterControl.buttonController.createTextBox("Your shield was burned!"); } }
public void addSpriteToList(int depth, CActor sprite) { if (!_drawList.ContainsKey(depth)) { _drawList.Add(depth, new List <CActor>()); } _drawList[depth].Add(sprite); }
public override void collide(object sender, CActor collider) { base.collide(sender, collider); if (!(collider is Actors.NPC.Enemies.Poe.CPoe)) { _killMe = true; } }
public override void collide(object sender, CActor collider) { base.collide(sender, collider); if (collider is Player.CPlayer) { _killMe = true; collider.stun(_STUN_TIME); CMasterControl.audioPlayer.addSfx(CMasterControl.audioPlayer.soundBank["Npc:redead:screech"]); } }
public override void collide(object sender, CActor collider) { if (collider is Player.CPlayer) { if (!INVINCIBLE_STATES.Contains(collider.state)) { collider.shock(); collider.dealDamange(2, collider); } } }
public CActor removeActorFromComponent(int componentAddress, CActor actor) { var toRemove = _componentRegistry[componentAddress].actors.Where(pair => pair.Value == actor) .Select(pair => pair) .ToList(); CActor outPut = toRemove[0].Value; _componentRegistry[componentAddress].actors.Remove(toRemove[0].Key); return(outPut); }
public override void collide(object sender, CActor collider) { if (_state == ACTOR_STATES.FOLLOW_PLAYER) { if (collider is Player.CPlayer) { _killMe = true; CMasterControl.audioPlayer.stopSfx(CMasterControl.audioPlayer.soundBank["Items:boomerang"]); } } }
// Use this for initialization void Start() { _currentPrice = 3; Debug.Log(_currentPrice.ToString()); CActor tActor; tActor = new CActor(); tActor.DoDo(); }
public void CreateRyu() { //툴에서 연결하지 않고 소스코드상에서 연결한다. mpUI = FindObjectOfType <CUI> (); mpActor = FindObjectOfType <CActor> (); mpEnemy = FindObjectOfType <CEnemy> (); mpUI.CreateRyu(); mpUI.SetScene(this); }
public void removeSpriteFromDrawList(CActor sprite) { int depth = sprite.drawDepth; if (!_drawList.ContainsKey(depth)) { return; } _drawList[depth].Remove(sprite); }
public void changeSpriteDepth(CActor sprite, int currentDepth, int newDepth) { _drawList[currentDepth].Remove(sprite); if (!_drawList.ContainsKey(newDepth)) { _drawList.Add(newDepth, new List <CActor>()); } _drawList[newDepth].Add(sprite); sprite.drawDepth = newDepth; }
public void addActorToComponent(CActor actor, int componentId) { CComponent component = queryComponentRegistry(componentId); if (component != null && component.actors != null && !component.actors.ContainsKey(actor.name)) { component.addActor(actor, actor.name); addToActorRegistry(actor); _layers[actor.layer].addToDrawList(actor); } }
public override void collide(object sender, CActor collider) { _killMe = true; if (collider is Player.CPlayer) { if (!INVINCIBLE_STATES.Contains(collider.state)) { collider.dealDamange(4, collider); } } }
void Create() { CActor pnn = new CActor(); pnn.value = int.Parse(Firstvalue.Text); pnn.flagfit = 0; processes.Add(pnn); CActor pnn1 = new CActor(); pnn1.value = int.Parse(Secondvalue.Text); pnn.flagfit = 0; processes.Add(pnn1); CActor pnn2 = new CActor(); pnn.flagfit = 0; pnn2.value = int.Parse(Thirdvalue.Text); processes.Add(pnn2); CActor pnn3 = new CActor(); pnn.flagfit = 0; pnn3.value = int.Parse(Fourthvalue.Text); processes.Add(pnn3); CActor pnn4 = new CActor(); pnn4.value = int.Parse(textBox1.Text); portions.Add(pnn4); CActor pnn5 = new CActor(); pnn5.value = int.Parse(textBox2.Text); portions.Add(pnn5); CActor pnn6 = new CActor(); pnn6.value = int.Parse(textBox3.Text); portions.Add(pnn6); CActor pnn7 = new CActor(); pnn7.value = int.Parse(textBox4.Text); portions.Add(pnn7); CActor pnn8 = new CActor(); pnn8.value = int.Parse(textBox5.Text); portions.Add(pnn8); //MessageBox.Show("Processes are" + processes[0].value + ", " + processes[1].value + ", " + processes[2].value + ", " + processes[3].value); }
public override void collide(object sender, CActor collider) { if (collider is Items.Swords.CSword) { if (_state != ACTOR_STATES.KNOCKBACK) { //start a moveback timer //change state to knockBack startTimer0(10); _state = ACTOR_STATES.KNOCKBACK; } } }
public override void collide(object sender, CActor collider) { if (collider is Player.CPlayer) { if (CMasterControl.hasFlippers) { } else { _drownPlayer(collider); } } }
public override void collide(object sender, CActor collider) { base.collide(sender, collider); if (collider is Player.CPlayer) { if (!INVINCIBLE_STATES.Contains(collider.state)) { collider.freeze(); collider.dealDamange(1, collider); } } }
private void solidCollide(CActor collider) { //Calculate How much to move to get out of collision moving towards last collisionless point CHitBox otherbox = collider.hitBox; //Calculate how far in we went float distx = (collider.position.X + otherbox.center.X) - (position.X + hitBox.center.X); distx = (float)Math.Sqrt(distx * distx); float disty = (position.Y + hitBox.center.Y) - (collider.position.Y + otherbox.center.Y); disty = (float)Math.Sqrt(disty * disty); float lenx = hitBox.halfWidth + otherbox.halfWidth; float leny = hitBox.halfHeight + otherbox.halfHeight; int px = 1; int py = 1; if (collider.position.X + otherbox.center.X < position.X + hitBox.center.X) { px = -1; } if (collider.position.Y + otherbox.center.Y < position.Y + hitBox.center.Y) { py = -1; } float penx = px * (distx - lenx); float peny = py * (disty - leny); //Resolve closest to previous position float diffx = (position.X + penx) - _oldPosition.X; diffx *= diffx; float diffy = (position.Y + peny) - _oldPosition.Y; diffy *= diffy; if (diffx < diffy) { _position.X += penx; //TODO: dont make a new vector every time } else if (diffx > diffy) { _position.Y += peny; //Same here } else { position = new Vector2(position.X + penx, position.Y + peny); //Corner cases } }
public override void collide(object sender, CActor collider) { _cancelPath(); if (_state == ACTOR_STATES.EXPLODE) { } else { if (collider is Actors.Collision.CSolidTile || collider is Actors.NPC.Enemies.CBaseEnemy || collider is Items.shields.CBaseShield) { _blowUp(); } } }
Vector3 _vecStartingPos; // Pose and rotation stored so we can return to 'configure' game mode at any time #endregion Fields #region Methods public static CJointDriver Create(CActor oActor, CJointDriver oJointDrvParent, string sNameBone, float nDriveStrengthMult, float nMass, float XL, float XH, float YHL, float ZHL, int nFinalized=0) { Transform oTransform; if (oJointDrvParent == null) oTransform = CUtility.FindChild(oActor._oBody._oBodyBase._oBonesT, sNameBone); // Finding bone when root is different. ###IMPROVE: Can be simplified to just always top bone? (e.g. Why does 'Bones' have a single top bone 'chestUpper' when the could be merged?) else oTransform = CUtility.FindChild(oJointDrvParent.transform, sNameBone); if (oTransform == null) CUtility.ThrowException("CJointDriver.Create() cannot find bone " + sNameBone); CJointDriver oJointDriver = CUtility.FindOrCreateComponent(oTransform.gameObject, typeof(CJointDriver)) as CJointDriver; oJointDriver.Initialize(oActor, oJointDrvParent, nDriveStrengthMult, nMass, XL, XH, YHL, ZHL, nFinalized!=0); return oJointDriver; }
public override void collide(object sender, CActor collider) { base.collide(sender, collider); if (collider is Projectiles.CArrow) { Projectiles.CArrow arrow = (Projectiles.CArrow)collider; if (arrow.isIce) { _state = ACTOR_STATES.FROZEN; swapImage(_IDLE); CMasterControl.commNet[this.componentAddress].Add(new CActorPacket(0, _name + "lantern", this)); startTimer1(1800); } } }
public virtual void SetActor(CActor actor) { if (actor == null) { return; } _actor = actor; Vector3 s, t; Quaternion r; bool success = actor.Matrix.Decompose(out s, out r, out t); if (!success) throw new Exception(); _scale = Matrix.CreateScale(s); _translation = Matrix.CreateTranslation(t); _actorRotation = Matrix.CreateFromQuaternion(r); }
public static NonCar GenerateNonCar(CActor actor, List<NoncarFile> nonCars) { if (actor.Model == null) return null; if (actor.Name.StartsWith("&")) { int index = int.Parse(actor.Name.Substring(1, 2)); NoncarFile nonCarFile = nonCars.Find(a => a.IndexNumber == index); if (nonCarFile == null) { Debug.WriteLine("No noncar matching " + actor.Name); return null; } ActorDescription actorDesc = new ActorDescription(); actorDesc.BodyDescription = new BodyDescription() { Mass = nonCarFile.Mass }; BoxShapeDescription boxDesc = new BoxShapeDescription(); boxDesc.Size = nonCarFile.BoundingBox.GetSize(); boxDesc.LocalPosition = nonCarFile.BoundingBox.GetCenter(); actorDesc.Shapes.Add(boxDesc); foreach (Vector3 extraPoint in nonCarFile.ExtraBoundingBoxPoints) { SphereShapeDescription extra = new SphereShapeDescription(0.2f); extra.LocalPosition = extraPoint; extra.Mass = 0; actorDesc.Shapes.Add(extra); } Vector3 scaleout, transout; Quaternion b; bool success = actor.Matrix.Decompose(out scaleout, out b, out transout); //if (!success) throw new Exception(); Matrix m = Matrix.CreateFromQuaternion(b) * Matrix.CreateTranslation(transout); StillDesign.PhysX.Actor instance = PhysX.Instance.Scene.CreateActor(actorDesc); instance.GlobalPose = m; instance.SetCenterOfMassOffsetLocalPosition(nonCarFile.CenterOfMass); instance.Group = PhysXConsts.NonCarId; //foreach (Shape s in instance.Shapes) // s.SetFlag(ShapeFlag.Visualization, false); NonCar noncar = new NonCar { Config = nonCarFile, CActor = actor }; instance.UserData = noncar; actor.AttachToPhysX(instance); if (nonCarFile.BendAngleBeforeSnapping > 0) { noncar.AttachToGround(); } instance.Sleep(); return noncar; } else { return null; } }
public ActFile(string filename) { Stream file = OpenDataFile(filename); if (!Exists) return; EndianBinaryReader reader = new EndianBinaryReader(EndianBitConverter.Big, file); CActor currentActor = null; Stack<CActor> actorStack = new Stack<CActor>(); List<CActor> flatActorList = new List<CActor>(); while (true) { int blockLength = 0; ActorBlockType blockType = (ActorBlockType)reader.ReadInt32(); blockLength = reader.ReadInt32(); switch (blockType) { case ActorBlockType.Name: currentActor = new CActor(); if (actorStack.Count == 0) { _actors.Add(currentActor); } else { CActor parent = actorStack.Peek(); currentActor.Parent = parent; parent.Children.Add(currentActor); } flatActorList.Add(currentActor); actorStack.Push(currentActor); currentActor.Flags = reader.ReadBytes(2); currentActor.SetName(ReadNullTerminatedString(reader)); break; case ActorBlockType.TransformMatrix: Matrix matrix = new Matrix(); matrix.M11 = reader.ReadSingle(); matrix.M12 = reader.ReadSingle(); matrix.M13 = reader.ReadSingle(); matrix.M21 = reader.ReadSingle(); matrix.M22 = reader.ReadSingle(); matrix.M23 = reader.ReadSingle(); matrix.M31 = reader.ReadSingle(); matrix.M32 = reader.ReadSingle(); matrix.M33 = reader.ReadSingle(); matrix.M41 = reader.ReadSingle(); matrix.M42 = reader.ReadSingle(); matrix.M43 = reader.ReadSingle(); matrix.M44 = 1; currentActor.Matrix = matrix; break; case ActorBlockType.HierarchyStart: //Debug.WriteLine("Hierarchy start"); break; case ActorBlockType.ActorEnd: actorStack.Pop(); //Debug.WriteLine("Hierarchy end"); break; case ActorBlockType.MaterialNames: currentActor.MaterialName = ReadNullTerminatedString(reader); break; case ActorBlockType.ModelName: string modelName = ReadNullTerminatedString(reader); currentActor.ModelName = modelName; break; case ActorBlockType.BoundingBox: currentActor.BoundingBox = new BoundingBox( new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()) * GameVars.Scale, new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()) * GameVars.Scale ); break; case ActorBlockType.Null: break; default: reader.Seek(blockLength, SeekOrigin.Current); break; } if (reader.BaseStream.Position == reader.BaseStream.Length) break; } reader.Close(); _actors.ResolveMaterials(); }
public void Initialize(CActor oActor, CJointDriver oJointDrvParent, float nDriveStrengthMult, float nMass, float XL, float XH, float YHL, float ZHL, bool bFinalized) { _oActor = oActor; _oJointDrvParent = oJointDrvParent; _nDriveStrengthMult = nDriveStrengthMult; _vecStartingPos = transform.localPosition; _quatStartingRotation = transform.localRotation; if (CGame.INSTANCE.BoneDebugMode && bFinalized == false) { // Set debug limits if in debug mode (so we can fully rotate along all axis for game-time tuning) unless bone is 'finalized' in which do apply the supplied limits _XH = _YHL = _ZHL = 177f; // Set limit angles to maximum value in bone debug mode (so runtime bone debugger can move all bones and all axis all the way) _XL = -_XH; } else { _XL = XL; _XH = XH; _YHL = YHL; _ZHL = ZHL; } //=== Create the rigid body for our bone === _oRigidBody = (Rigidbody)CUtility.FindOrCreateComponent(gameObject, typeof(Rigidbody)); //###TODO: Add a "CRigidBodyWake"??? _oRigidBody.mass = nMass; _oRigidBody.drag = 1.5f; //###TODO!! //###DESIGN: Which drag?? //###TUNE!!!!! ###IMPROVE: Different settings for arms & legs??? _oRigidBody.angularDrag = 1.5f; //###TUNE!!!! _oRigidBody.sleepThreshold = 0; // Ensure the rigid body never sleeps! //=== Process special handling needed when we are root (we are kinematic and we have no joint to parent) === if (_oJointDrvParent == null) { // If we have a null parent then we're the root and we're kinematic with no joint to anyone! _oRigidBody.isKinematic = true; } else { //=== If we have a parent then we are not kinematic and rotate by PhysX simulation === _oRigidBody.isKinematic = false; //=== Create the D6 configurable joint between our parent and us === _oConfJoint = (ConfigurableJoint)CUtility.FindOrCreateComponent(gameObject, typeof(ConfigurableJoint)); //###TODO: Add a "CRigidBodyWake"??? _oConfJoint.connectedBody = _oJointDrvParent._oRigidBody; //=== Set the joint limits as per our arguments === bool bInvertX = (_XL > _XH); //###OBS??? If the logical range is inverted we can't send this to PhysX as lowAngularXLimit MUST be < than highAngularXLimit! if (bInvertX) CUtility.ThrowException("Inverted XL / XH in bone " + gameObject.name); //###CHECK SoftJointLimit oJL = new SoftJointLimit(); //###IMPROVE: Has other fields that could be of use? oJL.limit = bInvertX ? _XH : _XL; _oConfJoint. lowAngularXLimit = oJL; // X is the high-functionality axis with separately-defined Xmin and Xmax... Y and Z only have a +/- range around zero, so we are forced to raise the lower half to match the other side oJL.limit = bInvertX ? _XL : _XH; _oConfJoint.highAngularXLimit = oJL; oJL.limit = _YHL; _oConfJoint. angularYLimit = oJL; //###NOTE! Hugely inconvenient feature of D6 joint is Y & Z must be symmetrical!! Make sure bone is oriented so X is used for the assymetrical rotation!! oJL.limit = _ZHL; _oConfJoint. angularZLimit = oJL; //=== Set joint axis defaults (before overriding some of them) === _oConfJoint.xMotion = _oConfJoint.yMotion = _oConfJoint.zMotion = ConfigurableJointMotion.Locked; _oConfJoint.angularXMotion = _oConfJoint.angularYMotion = _oConfJoint.angularZMotion = ConfigurableJointMotion.Limited; //###DESIGN? Limited vs Free? //=== Free the axis that don't need driving === ###CHECK: Safe??? if (_XL == 0f && _XH == 0f) _oConfJoint.angularXMotion = ConfigurableJointMotion.Free; // If an axis is unused set it //free to reduce PhysX workload ###CHECK: Is this ever invoked? Does it make joint fail if not all three axis driven?? if (_YHL == 0f) _oConfJoint.angularYMotion = ConfigurableJointMotion.Free; //###DESIGN: Verify unsetting! if (_ZHL == 0f) _oConfJoint.angularZMotion = ConfigurableJointMotion.Free; //###NOTE: SLERP needs all three axis by definition... But Limited of little / no use if we drive all the time (less PhysX overhead)) //=== Set the configurable joint drive strength === JointDrive oDrive = new JointDrive(); oDrive.positionSpring = _nDriveStrengthMult * CGame.INSTANCE.BoneDriveStrength; // Final spring strength is the global constant multiplied by the provided multiplier... makes it easy to adjust whole-body drive strength oDrive.positionDamper = 0; //###TODO!!!!! ###TUNE? oDrive.maximumForce = float.MaxValue; //###IMPROVE: Some reasonable force to prevent explosions?? //oDrive.mode = JointDriveMode.Position; _oConfJoint.slerpDrive = oDrive; _oConfJoint.rotationDriveMode = RotationDriveMode.Slerp; // Slerp is really the only useful option for bone driving. (Many other features of D6 joint!!!) //=== If we're a node on the right side, copy the collider defined on our twin node on the left side === if (_oActor._eBodySide == EBodySide.Right) { Transform oNodeSrc = CUtility.FindSymmetricalBodyNode(transform.gameObject); //Debug.Log("Collider copy " + oNodeSrc.name); Collider oColBaseSrc = oNodeSrc.GetComponent<Collider>(); if (oColBaseSrc.GetType() == typeof(CapsuleCollider)) { CapsuleCollider oColSrc = (CapsuleCollider)oColBaseSrc; CapsuleCollider oColDst = (CapsuleCollider)CUtility.FindOrCreateComponent(transform, typeof(CapsuleCollider)); oColDst.center = oColSrc.center; oColDst.radius = oColSrc.radius; oColDst.height = oColSrc.height; oColDst.direction = oColSrc.direction; } else if (oColBaseSrc.GetType() == typeof(BoxCollider)) { BoxCollider oColSrc = (BoxCollider)oColBaseSrc; BoxCollider oColDst = (BoxCollider)CUtility.FindOrCreateComponent(transform, typeof(BoxCollider)); oColDst.center = oColSrc.center; oColDst.size = oColSrc.size; } } } }