private void Collided() { PawnControler pc = FindObjectOfType <PawnControler>(); FindObjectOfType <BattleManager>().GetComponent <Animator>().SetTrigger("Collided"); GetComponent <PawnShadow>().DisableShadow(); }
public Vector2i?RegisterPawn(PawnControler pawnControler) { Vector2i gridCoordinate = HexagonUtils.ConvertOrthonormalToHexaSpace(pawnControler.transform.position); if (HexData.Contains(gridCoordinate)) { HexData[gridCoordinate].LocalPawns.Add(pawnControler); return(gridCoordinate); } return(null); }
void DestroyPawn(PawnControler target, int amount) { GameObject m = target.master; if (m != null) { m.GetComponent <CurserMovement>().pawns += amount; } if (amount < 0) { StartScreenShake(target.strentgh); PlaySoundEffect(strentgh, "destruction"); Destroy(target.gameObject); } }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { pc = FindObjectOfType <PawnControler>(); i = 0; }
void Raycast(Vector3 direction) { RaycastHit ray; if (Physics.Raycast(transform.position, direction, out ray, 1)) { GameObject targetObject = ray.collider.gameObject; PawnControler targetPawn = targetObject.GetComponent <PawnControler>(); if (targetPawn == null) { return; } //if this pawn moves into a space with a pawn of the same player, it absorbs it and gains its strength //neutral pawns have a player number below zero, and are also adding to this pawnn's count //but only if they have the exact same strength if (((playerNumber == targetPawn.playerNumber) || (targetPawn.playerNumber < 0)) && (strentgh == targetPawn.strentgh)) { strentgh += targetPawn.strentgh; textM.text = strentgh.ToString(); transform.position = targetObject.transform.position; if (master != null) { master.transform.position = transform.position; } DestroyPawn(targetPawn, -1); } //if the pawn is stronger, it just destroys the other cube else if (strentgh > targetPawn.strentgh) { //strentgh += targetPawn.strentgh; transform.position = targetObject.transform.position; if (master != null) { master.transform.position = transform.position; } DestroyPawn(targetPawn, -1); } //if the pawn is weaker, it gets destroyed else if (strentgh < targetPawn.strentgh) { //strentgh += targetPawn.strentgh; transform.position = targetObject.transform.position; if (master != null) { master.transform.position = transform.position; } DestroyPawn(this, -1); } //if the cube we move into is the same strength but not of the same or a neutral faction //, we normally want to destroy both else if (strentgh == targetPawn.strentgh) { //eccept, if this cube is a neutral cube, because then it is (as determined earlier into an other player) //and it should be absorbed by it if (playerNumber < 0) { targetPawn.strentgh += strentgh; targetPawn.textM.text = targetPawn.strentgh.ToString(); transform.position = targetObject.transform.position; DestroyPawn(this, -1); } //but if that is not the case, we still want to destroy both else { transform.position = targetObject.transform.position; if (master != null) { master.transform.position = transform.position; } DestroyPawn(this, -1); DestroyPawn(targetPawn, -1); } } //in this case there is nothing in our way and we can move our cube there } else { transform.position += direction; if (master != null) { master.transform.position = transform.position; StartScreenShake(this.strentgh / 2); PlaySoundEffect(strentgh, "walking"); } } }