void Update() { myNameText.text = myCard.gameObject.name; PlayerScript player = null; Transform parent = myCard.transform.parent; if (parent) { HandScript hand = parent.GetComponent <HandScript>(); if (hand) { player = hand.myOwningPlayer; } } if (player) { Message message = player.ToMessage(); mySupplyText.text = EmptyZero(myCard.mySupply.Cost(message)); myGoldText.text = EmptyZero(myCard.myGold.Cost(message)); myManaText.text = EmptyZero(myCard.myMana.Cost(message)); myOverText.text = EmptyZero(myCard.myOverload.Cost(message)); myDebtText.text = EmptyZero(myCard.myDebt.Cost(message)); } else { mySupplyText.text = EmptyZero(myCard.mySupply.myBase); myGoldText.text = EmptyZero(myCard.myGold.myBase); myManaText.text = EmptyZero(myCard.myMana.myBase); myOverText.text = EmptyZero(myCard.myOverload.myBase); myDebtText.text = EmptyZero(myCard.myDebt.myBase); } }
void checkGrab(HandScript hand, RaycastHit hit) { if (hit.distance < hand.armLength) { aSource.PlayOneShot(grabClip); grabbing = true; hand.grabHold(hit); Vector3 upVector = VectorFunctions.parallelVectorToNormal(transform.up, hit.normal); if (upVector == Vector3.zero) { upVector = -hand.side * Vector3.Cross(transform.forward, hit.normal); print("altered"); } Vector3 forwardVector = hand.side * Vector3.Cross(upVector, hit.normal); //print("normal: " + hit.normal); //print("upVector: " + upVector); // print(upVector.normalized); targetRotation = Quaternion.LookRotation(forwardVector, upVector); //targetPosition = hit.point + 0.7f * hit.normal - 1f*forwardVector.normalized; targetPosition = hit.point - hand.restingPoint.x * hit.normal - hand.restingPoint.y * upVector.normalized - hand.restingPoint.z * forwardVector.normalized; //print(VectorFunctions.findVectorInDirection(new Vector3(-1, 0, 0), new Vector3(1, 0, 0))); } else { grabbing = false; hand.releaseHold(); } }
// Use this for initialization void Awake() { hand = GameObject.Find("cat_hand").GetComponent <HandScript>(); hand.hideShowMesh(true); alphaVal = 1.0f; decUnit = 0.2f; isPausing = false; myMR = this.GetComponent <MeshRenderer>(); mats = myMR.materials;; myCols = new Color[mats.Length]; /**/ int i = 0; foreach (Material mat in mats) { //Debug.Log("*" + i.ToString() + "* " + mat.ToString()); Color myCol = mat.color; myCols[i] = myCol; i++; } parentHoleScript = null; } // Update is called once per frame void Update() { if (parentHoleScript == null) { parentHoleScript = this.gameObject.transform.parent.gameObject.GetComponent <HoleScript>(); } if (!isPausing) { if (alphaVal >= 0.0f) { /*myCol.a = alphaVal; * myMR.material.color = myCol;*/ int i = 0; foreach (Material mat in mats) { // 아... 되는건가.. Color myCol = myCols[i]; myCol.a = alphaVal; mat.color = myCol; i++; } // Decrease alpha alphaVal -= decUnit; }
// Use this for initialization void Start() { scriptObject = GameObject.Find("ScriptObject"); gameRunner = scriptObject.GetComponent <GameRunner>(); // handObject = GameObject.Find("HandRunner"); handRunner = handObject.GetComponent <HandScript>(); }
// Use this for initialization void Start() { leftHandMovementScript = transform.GetComponent <HandScript>(); objectToCut = transform.GetChild(0).gameObject; objectToCut.gameObject.SetActive(false); isBusy = false; }
// Start is called before the first frame update void Start() { leftHandScript = leftHand.GetComponent <HandScript>(); rightHandScript = rightHand.GetComponent <HandScript>(); loadingBarScript = bar.GetComponent <LoadingBarScript>(); prevBarAngle = bar.transform.rotation.eulerAngles; CursorManager.Instance.SetCursorVisible(false); }
public static int RemaningLife = 2; // <-- e' static perche' sono le 5.07 e ho sonno e non ho voglia di pensarci // Use this for initialization void Start() { rightHandMovementScript = transform.GetComponent <HandScript>(); knifeEventScript = transform.GetComponentInChildren <KnifeBehavior>(); // Utile per il life manager lifeController = GameObject.Find("Canvas").GetComponent <LifeController>(); }
private void Awake() { m_Pose = GetComponent <SteamVR_Behaviour_Pose>(); m_rotationFix = this.gameObject.transform.GetChild(0); m_lineRenderer = GetComponent <LineRenderer>(); m_HandScript = GetComponent <HandScript>(); m_HandScript.m_rotationFix = this.m_rotationFix; m_Player = GameObject.FindGameObjectWithTag("Player").transform; }
// Use this for initialization void Start() { d = GameObject.FindGameObjectWithTag("CardHandler").GetComponent <Deck> (); hand = GameObject.FindGameObjectWithTag("Hand").GetComponent <HandScript> (); GameObject cardo = Instantiate(cardTemplate, gameObject.transform); cardo.GetComponent <CardReader> ().SetCard(hand.handArray [hand.numCards - 1]); cardo.GetComponent <CardReader> ().SetScale(.5f, .5f, .5f); }
private void Start() { if (Instance == null) { Instance = this; } tempCard = GetComponent <CardScript>(); ChangeTurn(); }
public void Start() { this.Inputs = (InputManager)this.GetComponent("InputManager"); Time.timeScale = (float)1; float time = Time.time; this.rigid = (Rigidbody2D)this.GetComponent(typeof(Rigidbody2D)); this.hand = (HandScript)this.gameObject.transform.Find("Hand").GetComponent("HandScript"); audio = GetComponent <AudioSource>(); }
void moveBody(Vector3 mouseChange, HandScript handAnchor) { Vector3 change = 0.1f * (mouseChange[1] * -transform.forward + mouseChange[0] * -transform.right); Vector3 newPosition = targetPosition + change; if ((newPosition - handAnchor.transform.position).magnitude <= handAnchor.armLength) { targetPosition = newPosition; } }
void OnMouseDrag() { HandScript handScript = myHandScript; if (null != handScript && handScript.myOwningPlayer == GlobalScript.ourGlobalScript.myMainPlayerScript) { transform.position = Camera.main.ScreenToWorldPoint(GlobalScript.ourCursorScript.Cursor()); myPosition.Reset(transform.localPosition); } }
//private Vector3 lastMousePos; // Start is called before the first frame update void Start() { body = GetComponent <Rigidbody>(); aSource = GetComponent <AudioSource>(); InitJoints(); activeHand = leftHand; inactiveHand = rightHand; //lastMousePos = Input.mousePosition; }
// Use this for initialization void Start() { //get components hand = GetComponentInChildren <HandScript>(); aSource = GetComponent <AudioSource>(); //coroutine IDs coroutines = 0; //save the origin point so we can return there later originPoint = transform.position; //only start moving once called by the cake script StartCoroutine(_MoveTowardsTarget()); }
private void Awake() { if (instance == null) { instance = this; } else if (instance != null) { Destroy(this.gameObject); } icon = GetComponent <Image>(); }
private void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } }
public void OnMouseDown() { Debug.Log("I pressed the button"); handScript = Hand.GetComponent <HandScript> (); if (handScript.ToolInHand == 1) // 0 means nothing { GetComponent <SpriteRenderer> ().sprite = soil_tile; } else if (handScript.ToolInHand == 2) { GetComponent <SpriteRenderer> ().sprite = farm_tile; } }
void OnMouseExit() { HandScript handScript = myHandScript; if (handScript && GlobalScript.ourCursorScript.myCardScript != this) { myRotation.Animate(handScript.CardRotation(this), .2f); myPosition.Animate(handScript.CardPosition(this), .2f); mySize.Animate(new Vector3(.5f, .75f, .01f), .2f); } }
void OnMouseDown() { GlobalScript.ourCursorScript.myCardScript = this; HandScript handScript = myHandScript; if (null != handScript && handScript.myOwningPlayer == GlobalScript.ourGlobalScript.myMainPlayerScript) { GlobalScript.ourCursorScript.CursorDown(transform); mySize.Animate(new Vector3(.25f, .375f, .01f), .2f); myRotation.Animate(Quaternion.Euler(0f, 0f, 0f), 0.2f); } }
public void OnMouseDown() { Debug.Log("I pressed the button"); handScript = Hand.GetComponent <HandScript> (); if (handScript.ToolInHand == 0) // 0 means nothing { GetComponent <SpriteRenderer>().sprite = button_down; handScript.ToolInHand = 1; // 1 means hoe } else if (handScript.ToolInHand == 1) { GetComponent <SpriteRenderer>().sprite = button_up; handScript.ToolInHand = 0; } //handScript.ToolInHand = "hoe"; Debug.Log("you are " + handScript.ToolInHand); }
void checkHandMovement(HandScript hand) { Ray ray = mainCam.ScreenPointToRay(Input.mousePosition); RaycastHit[] hits = Physics.RaycastAll(ray); int chosenHit = -1; for (int i = 0; i < hits.Length; i++) { if (!hits[i].collider.isTrigger) { if (chosenHit == -1) { chosenHit = i; } else { if (hits[i].distance < hits[chosenHit].distance) { chosenHit = i; } } } } if (chosenHit != -1) { hand.targetPoint = hits[chosenHit].point; if (hits[chosenHit].distance > hand.armLength) { hand.targetPoint = ray.GetPoint(hand.armLength); } hand.moveToPoint = true; if (Input.GetMouseButton(0)) { checkGrab(hand, hits[chosenHit]); } } else { hand.targetPoint = ray.GetPoint(0.8f * hand.armLength); hand.moveToPoint = true; } }
public void PickUp(HandScript holder) { this.Holder = holder; this.rigid.isKinematic = true; int i = 0; Collider2D[] componentsInChildren = this.transform.GetComponentsInChildren <Collider2D>(); int length = componentsInChildren.Length; while (i < length) { componentsInChildren[i].enabled = false; i++; } int num = -1; Vector3 localScale = this.transform.localScale; float num2 = localScale.x = (float)num; Vector3 vector = this.transform.localScale = localScale; }
public void Drop() { transform.parent = null; if (this.Holder != null) { this.rigid.isKinematic = false; int i = 0; Collider2D[] componentsInChildren = this.transform.GetComponentsInChildren <Collider2D>(); int length = componentsInChildren.Length; while (i < length) { componentsInChildren[i].enabled = true; i++; } this.Holder = null; } if (MarkedForDeath) { Destroy(gameObject, 1); } righted = false; }
//Hand des Spielers Aktualisieren public void onChangePlayerCardHand(List <Karten> hand) { int x = 0; //Hand des Spielers Aktualisieren List<RawImage> PlayerHand; foreach (RawImage element in PlayerHand) { HandScript handKarte = element.GetComponent <HandScript>(); handKarte.Karte = null; if (hand.Count > x) { handKarte.Karte = hand[x].GetComponent <Karten>(); handKarte.HoverCard = HoverCard; element.enabled = true; element.GetComponent <RawImage>().texture = hand[x].gameObject.GetComponent <Renderer>().sharedMaterials[2].mainTexture; } else { element.enabled = false; } x++; } }
void Awake() { HoverCard = GameObject.FindWithTag("HoverCard"); instance = this; }
// Second version of calculating the value of a specified hand. // This version is for when an Ace has been found in a hand. The // result is that it will recursively loop through the hand looking // for Aces until either there are no Aces left, or the hand's value // is less than 21. This is the only way I could get this to work // without using a while loop, which crashed Unity despite the logic // being able to break out of the while loop. int CalculateValue(HandScript.Hand hand) { int handValue = 0; for(int i = 0; i < hand.cards.Count; i++) { handValue += hand.cards[i].nValue; } if(handValue > 21) { aceChanged = false; CheckAces(hand); if(aceChanged) { handValue = CalculateValue(hand); } } return handValue; }
// Look for a high value Ace, and make it a low value if one exists void CheckAces(HandScript.Hand hand) { for(int i = 0; i < hand.cards.Count; i++) { if(hand.cards[i].nValue == 11) { hand.cards[i].nValue = 1; aceChanged = true; break; } } }
void CheckBusts(HandScript.Hand hand) { if(hand.value > 21) { hand.bust = true; } if(handOne.isSplit && handOne.bust && handTwo.bust || !handOne.isSplit && handOne.bust) { availableHands = false; } }
void CheckWinCondition(HandScript.Hand hand) { payoutAmount = 0; if(surrender) { if(dealerHand.blackJack) { payoutAmount = 0; } else { payoutAmount += currentBet / 2; } } else { if(dealerHand.bust) { if(hand.value <= 21) { hand.win = true; } } else { if(isInsured) { if(dealerHand.blackJack) { payoutAmount += handOne.insuranceWinnings; } } if(hand.value <= 21 && hand.value > dealerHand.value) { hand.win = true; } else if(hand.value < dealerHand.value) { dealerHand.win = true; // Might not need this, could check for if player hands haven't won } else if(hand.value == dealerHand.value) { hand.push = true; } } if(hand.win) { if(hand.blackJack && hand.canAcceptBlackjack) { payoutAmount += hand.potentialWinnings * 3; } else { payoutAmount += hand.potentialWinnings * 2; } } else if(hand.push && !hand.bust) { payoutAmount += hand.potentialWinnings; } } totalChips += payoutAmount; }
//initialize deck void Awake() { gm = (GameManager)GameObject.Find("GameManager").GetComponent("GameManager"); //grab playerHand's Handscript component cardScript = cardObject.GetComponent<CardScript> (); playerScript = playerHand.GetComponent<HandScript> (); GameObject temp; for (int i=0; i<20; i++) { //instantiate a card object and give it its unique properties temp = (GameObject)Instantiate(cardObject); //set cardObject's texture Texture img = (Texture)Resources.Load("CardBack"); temp.GetComponent<Renderer>().material.mainTexture = img; cardScript.setCard(cardCategories[i], cardTypes[i]); _deck.Add (temp); } //shuffle the deck Shuffle (); oldPos = this.transform.position; if (this.name.Equals("P1Deck")) { playerID = 1; } else if (this.name.Equals("P2Deck")) { playerID = 2; } }
} //name used to refer to this effect in XML public override void trigger(ref PlayerCard card, GameObject card_gameObject) { HandScript handRef = PlayerHandScript.instance; handRef.StartCoroutine(handRef.discardRandomCards(card_gameObject.GetComponent <CardScript>(), Mathf.FloorToInt(strength))); }
public void DealCard(HandScript.Hand hand) { GameObject card; int randomCard = Random.Range(0, numCards); hand.cards.Add(deck[randomCard]); hand.value = CalculateValue(deck[randomCard].nValue, hand); deck.Remove(deck[randomCard]); numCards--; card = Instantiate(cardPrefab, cardStart.transform.position, Quaternion.identity) as GameObject; card.name = hand.cards[hand.cards.Count - 1].name; // Grab the texture from the textures list card.GetComponent<Renderer>().material.mainTexture = textures[hand.cards[hand.cards.Count - 1].texture]; if(!hand.isPlayer && hand.hand.Count == 0) { card.GetComponent<CardScript>().isRevealed = false; } else { card.GetComponent<CardScript>().isRevealed = true; } // Add the gameObject to the hand hand.hand.Add(card); }
void OnMouseUp() { GlobalScript.ourCursorScript.myCardScript = null; //store handscript because it's not free HandScript handScript = myHandScript; PlayerScript playerScript = handScript.myOwningPlayer; //check if card is main player's if (null != handScript && playerScript == GlobalScript.ourGlobalScript.myMainPlayerScript) { //card must be over 20% of the screen to be used //Debug.Log(Input.mousePosition.y / Screen.height); if (Input.mousePosition.y / Screen.height > .2f) { Message message = playerScript.ToMessage(); //raycast terrain Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, GlobalScript.ourCursorScript.myRayLength)) { message.myObject.myPosition = hit.point; } //raycast units if (Physics.Raycast(ray, out hit, GlobalScript.ourCursorScript.myRayLength, 1 << 9)) { UnitScript unitScript = hit.transform.GetComponent <UnitScript>(); if (unitScript) { message.myObject = unitScript.ToTerm(); } } //get cost of card int manaCost = CostMana(message); int goldCost = CostGold(message); //if player has enough if (manaCost <= playerScript.myMana) { if (goldCost <= playerScript.myGold) { //pay cost playerScript .SubMana(manaCost) .SubGold(goldCost) .AddDebt(CostDebt(message)) .AddOverload(CostOverload(message)); handScript.RemoveCard(this, false); playerScript.ActivateCard(this, message); Destroy(gameObject); } else { Debug.Log("Card: " + gameObject.name + " uses " + goldCost + " gold."); } } else { Debug.Log("Card: " + gameObject.name + " uses " + manaCost + " mana."); } return; } myPosition.Reset(transform.localPosition).Animate(myHandScript.CardPosition(this), .2f); myRotation.Reset(transform.localRotation).Animate(myHandScript.CardRotation(this), .2f); } }
void MoveCard(HandScript.Hand hand) { float step = speed * Time.deltaTime; for(int i = 0; i < hand.hand.Count; i++) { hand.hand[i].gameObject.transform.position = Vector3.MoveTowards(hand.hand[i].transform.position, new Vector3(hand.handArea.position.x + (i * 0.5f), hand.handArea.position.y + (i * 0.01f), hand.handArea.position.z), step); } }
public void ResetHand(HandScript.Hand hand) { hand.cards.Clear(); hand.hand.Clear(); hand.insuranceWinnings = 0; hand.potentialWinnings = 0; hand.value = 0; hand.active = false; hand.blackJack = false; hand.bust = false; hand.isSplit = false; hand.push = false; hand.stand = false; hand.win = false; }
public void EquipTheHoe() { handScript = Hand.GetComponent <HandScript> (); handScript.ToolInHand = 1; // 1 means hoe }
private void Start() { handScript = hand.GetComponent <HandScript>(); }