public void Init(AbilityContainer owner) { LastStartTime = 0; Controller = owner; Pawn = owner.GetComponent <BasePawn>(); OnInit(); }
//Called once public Order SendOrder(CommandType C) { switch (C) { case CommandType.Movement: Order MO = OF.createOrder(Checked, CC.GrabTransform()); StopValidation(); return(MO); case CommandType.TargetAbility: BasePawn V = CS.CheckValid(); if (V != null) { Order SO = OF.createOrder(C, V, -10); StopValidation(); return(SO); } else { return(null); } case CommandType.NonTargetAbility: throw new NotImplementedException(); default: Debug.Log("Nothin here!"); return(null); } }
public void DoThrow() { if (!TakenPawn) { return; } TakenPawn.transform.SetParent(null, true); var dirToPot = MainGame.Instance.Pot.transform.position - Pawn.transform.position; var distToPot = Vector3.Distance(MainGame.Instance.Pot.transform.position, Pawn.transform.position); if (Vector3.Dot(dirToPot, Pawn.transform.forward) > 0.25f && distToPot < MaxPotThrowDistance) { MainGame.Instance.Pot.ThrowToPot(TakenPawn); } else { TakenPawn.GetComponent <DeadBody>() .Throw(Vector3.Lerp(Pawn.transform.forward, Vector3.up, 0.5f) * ThrowForce); } TakenPawn = null; CurrentState = State.Idle; }
void DoRevive() { if (RevivedPawn || CurrentState == State.Take) { return; } CurrentState = State.Revive; foreach (var collider in Physics.OverlapSphere(Pawn.transform.position, ReviveRadius, QueryMask, QueryTriggerInteraction.Collide) .Where(p => { var dir = p.transform.position - Pawn.transform.position; return(Vector3.Dot(dir.normalized, Pawn.transform.forward) > 0.5f); }) .OrderBy(p => Vector3.Distance(p.transform.position, Pawn.transform.position))) { var pawn = collider.GetComponentInParent <BasePawn>(); if (pawn && !pawn.IsAlive()) { RevivedPawn = pawn; break; } } if (RevivedPawn) { StartCoroutine(ProcessRevive()); } }
public void Init(AbilityContainer controller) { Controller = controller; Pawn = Controller.GetComponent <BasePawn>(); LastBegin = 0; OnInit(); }
public void ThrowToPot(BasePawn pawn) { if (Processing.Contains(pawn.transform)) { return; } Processing.Add(pawn.transform); DoAnimate(pawn.transform); }
//For making sure the pawn is that player's pawn private bool ValidateSelectedPawn(BasePawn P) { foreach (BasePawn B in ThisPlayersPawns) { if (P.ID == B.ID) { return(true); } } return(false); }
void OnTriggerExit(Collider Other) { BasePawn PawnCheck = Other.gameObject.GetComponent <BasePawn>(); Obstacle OCheck = Other.gameObject.GetComponent <Obstacle>(); if (PawnCheck == null && OCheck == null) { valid = true; VisualCheck.GetComponent <MeshRenderer>().material = ValidMat; } }
void OnTriggerStay(Collider Other) { BasePawn PawnCheck = Other.gameObject.GetComponent <BasePawn>(); Obstacle OCheck = Other.gameObject.GetComponent <Obstacle>(); if (PawnCheck != null || OCheck != null) { valid = false; VisualCheck.GetComponent <MeshRenderer>().material = InvalidMat; } }
public void BPValidatorSetup(BasePawn P) { Checked = P; if (Checked != null) { CC = Checked.GetComponentInChildren <CheckCollider>(); CS = Checked.GetCS(); } else { throw new InvalidOperationException(); } }
public static void DrawCollider(CollisionInfo info, Transform transform, BasePawn pawn = null) { if (pawn) { var offset = pawn.transform.position + pawn.transform.rotation * info.Offset; Gizmos.DrawWireSphere(offset, info.Distance); } else { var offset = transform.position + transform.rotation * info.Offset; Gizmos.DrawWireSphere(offset, info.Distance); } }
//Generally for Shooting or for Ability casts public Order createOrder(CommandType Command, BasePawn P, int Value) { switch (Command) { case CommandType.NonTargetAbility: throw new NotImplementedException(); case CommandType.TargetAbility: return(new AttackOrder(P.ID, Value)); default: throw new InvalidOperationException(); } }
void SelectPawn(GameObject Obj) { if (Obj != null) { BasePawn P = Obj.GetComponentInParent <BasePawn>(); if (P != null) { if (ValidateSelectedPawn(P)) { SelectedPawn = P; GameMaster.SetFPSCam(P.PawnCam); PV.BPValidatorSetup(P); //Graphicy stuff! } } } }
//Grab the response from the Rulebook and apply it, though for now we are short cutting it.... public void ApplyResponse(Response R) { BasePawn TargetPawn = Pawns_In_Play[R.AppliedID]; if (TargetPawn != null) { TargetPawn.ExecuteCommand(R); if (TargetPawn == null) { //Remove it from the list } } else { throw new ArgumentNullException(); } }
//Movement public Order createOrder(BasePawn P, Transform Loc) { return(new MoveOrder(P.ID, Loc)); }
void DoTake() { if (!CanThrow) { return; } if (CurrentState == State.Take) { if (!TakenPawn) { CurrentState = State.Idle; Debug.DebugBreak(); return; } // Perform throw Pawn.Anim.SetLayerWeight(1, 0); Pawn.Anim.SetTrigger("DoThrow"); Pawn.MaxSpeed = 0; return; } if (CurrentState != State.Idle) { return; } var allColliders = Physics.OverlapSphere(Pawn.transform.position, ReviveRadius, QueryMask, QueryTriggerInteraction.Collide); foreach (var collider in allColliders .Where(p => { var dir = p.transform.position - Pawn.transform.position; return(Vector3.Dot(dir.normalized, Pawn.transform.forward) > 0.5f); }) .OrderBy(p => Vector3.Distance(p.transform.position, Pawn.transform.position))) { var pawn = collider.GetComponentInParent <BasePawn>(); if (pawn && !pawn.IsAlive()) { TakenPawn = pawn; break; } } if (TakenPawn) { CanThrow = false; var driver = TakenPawn.GetComponent <AIDriver>(); TakenPawn.GetComponent <DeadBody>().OnPickup(); // pull the plug driver.DisableInput(); TakenPawn.ResetBody(); Pawn.Anim.SetTrigger("OnTake"); StartCoroutine(AnimateLayer(0, 1)); StartCoroutine(AnimatePosition()); CurrentState = State.Take; var dir = (TakenPawn.transform.position - Pawn.transform.position).normalized; Pawn.LockFaceDirection(dir); Pawn.MaxSpeed = 0; } }