protected override async Task OnActivatedAsync(ActorActivationDetails details) { originPos = Transform.Pos; lastPos = originPos; type = (PlatformType)details.Params[0]; length = details.Params[3]; speed = (details.Params[2] > short.MaxValue ? -(ushort.MaxValue - details.Params[2]) : details.Params[2]) * 0.78f; ushort sync = details.Params[1]; isSwing = details.Params[4] != 0; phase = (BaseCycleFrames - (float)(Time.GameTimer.TotalMilliseconds % BaseCycleFrames - sync * 175) * speed) % BaseCycleFrames; CollisionFlags = CollisionFlags.CollideWithOtherActors | CollisionFlags.IsSolidObject; IsOneWay = true; canBeFrozen = false; await RequestMetadataAsync("MovingPlatform/" + type.ToString("G")); SetAnimation("Platform"); pieces = new ChainPiece[length]; for (int i = 0; i < length; i++) { pieces[i] = new ChainPiece(levelHandler, originPos + new Vector3(0f, 0f, 4f), type); levelHandler.AddActor(pieces[i]); } }
public override void OnAttach(ActorInstantiationDetails details) { base.OnAttach(details); originPos = Transform.Pos; length = details.Params[2]; speed = (details.Params[1] > short.MaxValue ? -(ushort.MaxValue - details.Params[2]) : details.Params[2]) * 0.78f; ushort sync = details.Params[0]; isSwing = details.Params[3] != 0; shade = details.Params[4] != 0; phase = (BaseCycleFrames - (float)(Time.GameTimer.TotalMilliseconds % BaseCycleFrames - sync * 175) * speed) % BaseCycleFrames; isInvulnerable = true; collisionFlags = CollisionFlags.CollideWithOtherActors; canBeFrozen = false; RequestMetadata("Object/SpikeBall"); SetAnimation("SpikeBall"); pieces = new ChainPiece[length]; for (int i = 0; i < length; i++) { pieces[i] = new ChainPiece(api, originPos + new Vector3(0f, 0f, 4f), i); api.AddActor(pieces[i]); } }
public override void OnAttach(ActorInstantiationDetails details) { base.OnAttach(details); originPos = Transform.Pos; type = (PlatformType)details.Params[0]; length = details.Params[3]; speed = (details.Params[2] > short.MaxValue ? -(ushort.MaxValue - details.Params[2]) : details.Params[2]) * 0.78f; ushort sync = details.Params[1]; isSwing = details.Params[4] != 0; phase = (BaseCycleFrames - (float)(Time.GameTimer.TotalMilliseconds % BaseCycleFrames - sync * 175) * speed) % BaseCycleFrames; collisionFlags = CollisionFlags.CollideWithOtherActors | CollisionFlags.IsSolidObject; IsOneWay = true; canBeFrozen = false; RequestMetadata("MovingPlatform/" + type.ToString("G")); SetAnimation("Platform"); pieces = new ChainPiece[length]; for (int i = 0; i < length; i++) { pieces[i] = new ChainPiece(api, originPos + new Vector3(0f, 0f, 4f), type, i); api.AddActor(pieces[i]); } }
public Rigidbody2D CreateLink(string name, Vector3 pos, Vector2 dir, Rigidbody2D objectBefore) { GameObject standingObject = ObjectPool.instance.GetObjectForType(name); if (standingObject != null) { ChainPiece piece = standingObject.GetComponent <ChainPiece>(); if (piece != null) { piece.myHead = this; } HingeJoint2D linkHinge = standingObject.GetComponent <HingeJoint2D>(); linkHinge.connectedBody = objectBefore; DistanceJoint2D distanceJoint = standingObject.GetComponent <DistanceJoint2D>(); distanceJoint.connectedBody = objectBefore; //SpringJoint2D springJoint = standingObject.GetComponent<SpringJoint2D>(); //springJoint.connectedBody = objectBefore; standingObject.transform.position = pos; Rigidbody2D linkRigidBody = standingObject.GetComponent <Rigidbody2D>(); chainPieces.Add(linkRigidBody); return(linkRigidBody); } else { Debug.Log("something broke::: standingObject --" + standingObject + "--" + name); } return(null); }
protected override async Task OnActivatedAsync(ActorActivationDetails details) { originPos = Transform.Pos; length = details.Params[2]; speed = (details.Params[1] > short.MaxValue ? -(ushort.MaxValue - details.Params[2]) : details.Params[2]) * 0.78f; ushort sync = details.Params[0]; isSwing = details.Params[3] != 0; shade = details.Params[4] != 0; phase = (BaseCycleFrames - (float)(Time.GameTimer.TotalMilliseconds % BaseCycleFrames - sync * 175) * speed) % BaseCycleFrames; base.canBeFrozen = false; base.isInvulnerable = true; base.CollisionFlags = CollisionFlags.CollideWithOtherActors; await RequestMetadataAsync("MovingPlatform/SpikeBall"); SetAnimation("Platform"); pieces = new ChainPiece[length]; for (int i = 0; i < length; i++) { pieces[i] = new ChainPiece(levelHandler, originPos + new Vector3(0f, 0f, 4f), i); levelHandler.AddActor(pieces[i]); } }
// void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.tag == "Player") { //test chain they are holding } if (coll.gameObject.tag == "Chain") { if (testtimecount + testtime < Time.timeSinceLevelLoad) { bool foundone = false; // testtimecount = Time.timeSinceLevelLoad; // ChainPiece piece = coll.gameObject.GetComponent <ChainPiece>(); if (piece != null && piece.myHead.headBox != null) { if (piece.myHead.headBox != this && piece.myHead.tailBox != this) { foundone = true; for (int j = 0; j < connected.Count; j++) { if (connected[j] == piece.myHead.headBox || connected[j] == piece.myHead.tailBox) { //already connect foundone = false; } } } } if (foundone) { print("Do Bind " + this.name); connected.Add(piece.myHead.headBox); piece.myHead.tailBox = this; //create link GameObject standingObject = ObjectPool.instance.GetObjectForType("KineticJoin"); if (standingObject != null) { JoinToKinectic linker = standingObject.GetComponent <JoinToKinectic>(); linker.combine(GetComponent <Rigidbody2D>(), coll.gameObject.GetComponent <Rigidbody2D>(), coll); } // } } } }
protected override async Task OnActivatedAsync(ActorActivationDetails details) { endText = details.Params[1]; canBeFrozen = false; SetHealthByDifficulty(100); scoreValue = 3000; collisionFlags = CollisionFlags.CollideWithOtherActors; await RequestMetadataAsync("Boss/Bolly"); SetAnimation(AnimState.Idle); // Bottom bottom = new Bottom(); bottom.OnActivated(new ActorActivationDetails { Api = api }); bottom.Parent = this; // Turret turret = new Turret(); turret.OnActivated(new ActorActivationDetails { Api = api }); turret.Parent = this; // Chain const int ChainLength = 5 * 3; pieces = new ChainPiece[ChainLength]; for (int i = 0; i < ChainLength; i++) { pieces[i] = new ChainPiece(); pieces[i].OnActivated(new ActorActivationDetails { Api = api, Params = new ushort[] { (ushort)((i % 3) == 2 ? 0 : 1) } }); api.AddActor(pieces[i]); } }