void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag ("Player") || other.CompareTag ("Clone")) { presentMovement = other.GetComponent<GridMovement> (); presentMovement.IncrementDestinationByCurrentDirection (); } }
void OnTriggerExit2D(Collider2D other) { if (presentMovement) { presentMovement.isOnIce = false; presentMovement.ResetSpeed (); presentMovement = null; } }
void Awake() { movement = GetComponent<GridMovement>(); healthSlider.value = healthCur; ChangeHealth(); scoreText.text = score.ToString(); }
public static void RemoveUnit(GridMovement unit) { //if(turnKey.Contains(unit.tag)) //{ //Debug.Log(units); //Debug.Log(turnKey); //Debug.Log(turnTeam); //List<GridMovement> teamList = units[turnKey.Peek()]; //foreach (GridMovement target in teamList) //{ // Debug.Log(target.gameObject.tag); //} Debug.Log(unit); Debug.Log(units[unit.tag]); units[unit.tag].Remove(unit); if (units[unit.tag].Count == 0) { //units[unit.tag]); Debug.Log("Game Over"); if (unit.tag == "NPC") { winner = "Blue"; } else { winner = "Red"; } gameCont = false; } /*string init = turnKey.Dequeue(); * string team = init; * while (turnKey.Dequeue() != init) * { * turnKey.Enqueue(team); * }*/ //InitTeamTurnQueue(); //units.Remove(unit.tag); //turnKey = new Queue<string>(turnKey.Where(p => p != v)); //} }
// 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) { CurrentPos = animator.GetComponent <GridMovement>(); targetPos = GameObject.FindGameObjectWithTag("Player").GetComponent <GridMovement>(); Tiles = 0; playerWait = 0; if (animator.gameObject.tag == "E1") { combatLogic.E1Turn = true; } if (animator.gameObject.tag == "E2") { combatLogic.E2Turn = true; } if (animator.gameObject.tag == "E3") { combatLogic.E3Turn = true; } }
public static void EndTurn() { GridMovement unit = turnTeam.Dequeue(); unit.EndTurn(); if (turnTeam.Count > 0) { //start next teammeber's turn StartTurn(); } else { //remove team form front of list and add them to the back, then start next team's turn string team = turnKey.Dequeue(); turnKey.Enqueue(team); InitTeamTurnQueue(); } }
/*public void EndTurn() * { * GridMovement unit = turnTeam.Dequeue(); * unit.EndTurn(); * * if (turnTeam.Count > 0) * { * StartTurn(); * } * else * { * string team = turnKey.Dequeue(); * turnKey.Enqueue(team); * InitTeamTurnQueue(); * } * }*/ public static void AddUnit(GridMovement unit) { /*List<GridMovement> list; * * if (!units.ContainsKey(unit.tag)) * { * list = new List<GridMovement>(); * units[unit.tag] = list; * * if (!turnKey.Contains(unit.tag)) * { * turnKey.Enqueue(unit.tag); * } * } * else * { * list = units[unit.tag]; * } * //Debug.Log(unit.name); * list.Add(unit);*/ if (teamOne.Count == 0) { teamOne.Add(unit); teamOneType = unit.gameObject.tag; } else if (teamOneType == unit.gameObject.tag) { teamOne.Add(unit); } else { if (teamTwo.Count == 0) { teamTwo.Add(unit); teamTwoType = unit.gameObject.tag; } else if (teamTwoType == unit.gameObject.tag) { teamOne.Add(unit); } } }
public static void AddUnit(GridMovement unit) { List <GridMovement> list; if (!units.ContainsKey(unit.tag)) { list = new List <GridMovement> (); units[unit.tag] = list; if (!turnKey.Contains(unit.tag)) { turnKey.Enqueue(unit.tag); } } else { list = units[unit.tag]; } list.Add(unit); }
void LateUpdate() { Vector3 direction = GridMovement.GetDirectionFromInput (); if ((clone = cloneAbility.GetClone ())) { // intentional assignment cloneMovement = clone.GetComponent<GridMovement> (); if (!movement.IsMoving () && !cloneMovement.IsMoving ()) { movement.MoveInDirection (direction); cloneMovement.MoveInDirection (direction); } else if (cloneMovement.isOnIce && !movement.IsMoving ()) { movement.MoveInDirection (direction); } else if (movement.isOnIce && !cloneMovement.IsMoving ()) { cloneMovement.MoveInDirection (direction); } } else if (movement.enabled) { movement.MoveInDirection (direction); } }
void Start() { //Ensures all texts are disabled winText.SetActive(false); winText2.SetActive(false); loseText.SetActive(false); loseText2.SetActive(false); //Will cache the player's movement script to read it's movable states playerMove = player.GetComponent <GridMovement>(); //Loads the controller into the levelmanager controller = GameObject.Find("GameManager").GetComponent <GameControl>(); //Locates the child floorscripts under the tilemap and loads them into floorActivated floors = floorTilemap.GetComponentsInChildren <FloorScript>(); foreach (FloorScript floorTile in floors) { floorActivated.Add(floorTile); } }
// Update is called once per frame void Update() { GameObject theCharacter = GameObject.Find("GridMovement"); GridMovement characters = theCharacter.GetComponent <GridMovement>(); Ray r = new Ray(transform.position, characters.GetTransformCurrentCharacter().position - transform.position); RaycastHit hit; if (Physics.Raycast(r, out hit, 1000, fogLayer, QueryTriggerInteraction.Collide)) { for (int i = 0; i < vertices.Length; i++) { Vector3 v = fogOfWarPlane.transform.TransformPoint(vertices[i]); float dist = Vector3.SqrMagnitude(v - hit.point); if (dist < radiusSqr) { float alpha = Mathf.Min(colors[i].a, dist / radiusSqr); colors[i].a = alpha; } } UpdateColor(); } }
protected virtual void Awake() { if (m_GridObject == null) { m_GridObject = GetComponent <GridObject>(); if (m_GridObject == null) { m_GridObject = GetComponentInParent <GridObject>(); } } if (m_GridMovement == null) { m_GridMovement = GetComponent <GridMovement>(); if (m_GridMovement == null) { m_GridMovement = GetComponentInParent <GridMovement>(); } } if (m_OwnerHealth == null) { m_OwnerHealth = GetComponent <Health>(); if (m_OwnerHealth == null) { m_OwnerHealth = GetComponentInParent <Health>(); } } // Finds and adds the attack triggers for this attack AttackTrigger[] componentsInChildren = GetComponentsInChildren <AttackTrigger>(); foreach (AttackTrigger item in componentsInChildren) { if (!m_AttackTriggers.Contains(item)) { m_AttackTriggers.Add(item); item.m_Attack = this; } } }
// Update is called once per frame void Update() { if (GameObject.FindWithTag("E1") && enemy1 == null) { enemy1 = GameObject.FindWithTag("E1").GetComponent <GridMovement>(); enemyCount++; } if (GameObject.FindWithTag("E2") && enemy2 == null) { enemy2 = GameObject.FindWithTag("E2").GetComponent <GridMovement>(); enemyCount++; } if (GameObject.FindWithTag("E3") && enemy3 == null) { enemy3 = GameObject.FindWithTag("E3").GetComponent <GridMovement>(); enemyCount++; } if (Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.Joystick1Button7)) { if (targeting == false) { targeting = true; } else { targeting = false; targetCount = 0; combatLogic.target = targetCount; combatLogic.targeting = false; } } if (targeting == true) { if (enemyCount == 3) { if (PlayerPos.Ypos == enemy1.Ypos && enemy1.Ypos == enemy2.Ypos && enemy1.Ypos == enemy3.Ypos && enemy1.Xpos == Mathf.Min(enemy1.Xpos, enemy2.Xpos, enemy3.Xpos)) { combatLogic.targeting = true; targetCount = 1; } else if (PlayerPos.Ypos == enemy1.Ypos && enemy1.Ypos == enemy2.Ypos && enemy1.Ypos != enemy3.Ypos && enemy1.Xpos == Mathf.Min(enemy1.Xpos, enemy2.Xpos)) { combatLogic.targeting = true; targetCount = 1; } else if (PlayerPos.Ypos == enemy1.Ypos && enemy1.Ypos != enemy2.Ypos && enemy1.Ypos == enemy3.Ypos && enemy1.Xpos == Mathf.Min(enemy1.Xpos, enemy3.Xpos)) { combatLogic.targeting = true; targetCount = 1; } else if (PlayerPos.Ypos == enemy1.Ypos && enemy1.Ypos != enemy2.Ypos && enemy1.Ypos != enemy3.Ypos) { combatLogic.targeting = true; targetCount = 1; } else if (PlayerPos.Ypos == enemy2.Ypos && enemy2.Ypos == enemy1.Ypos && enemy2.Ypos == enemy3.Ypos && enemy2.Xpos == Mathf.Min(enemy1.Xpos, enemy2.Xpos, enemy3.Xpos)) { combatLogic.targeting = true; targetCount = 2; } else if (PlayerPos.Ypos == enemy2.Ypos && enemy2.Ypos == enemy1.Ypos && enemy2.Ypos != enemy3.Ypos && enemy2.Xpos == Mathf.Min(enemy1.Xpos, enemy2.Xpos)) { combatLogic.targeting = true; targetCount = 2; } else if (PlayerPos.Ypos == enemy2.Ypos && enemy2.Ypos != enemy1.Ypos && enemy2.Ypos == enemy3.Ypos && enemy2.Xpos == Mathf.Min(enemy2.Xpos, enemy3.Xpos)) { combatLogic.targeting = true; targetCount = 2; } else if (PlayerPos.Ypos == enemy2.Ypos && enemy2.Ypos != enemy1.Ypos && enemy2.Ypos != enemy3.Ypos) { combatLogic.targeting = true; targetCount = 2; } else if (PlayerPos.Ypos == enemy3.Ypos && enemy3.Ypos == enemy1.Ypos && enemy3.Ypos == enemy2.Ypos && enemy3.Xpos == Mathf.Min(enemy1.Xpos, enemy2.Xpos, enemy3.Xpos)) { combatLogic.targeting = true; targetCount = 3; } else if (PlayerPos.Ypos == enemy3.Ypos && enemy3.Ypos == enemy1.Ypos && enemy3.Ypos != enemy2.Ypos && enemy3.Xpos == Mathf.Min(enemy1.Xpos, enemy3.Xpos)) { combatLogic.targeting = true; targetCount = 3; } else if (PlayerPos.Ypos == enemy3.Ypos && enemy3.Ypos != enemy1.Ypos && enemy3.Ypos == enemy2.Ypos && enemy3.Xpos == Mathf.Min(enemy2.Xpos, enemy3.Xpos)) { combatLogic.targeting = true; targetCount = 3; } else if (PlayerPos.Ypos == enemy3.Ypos && enemy3.Ypos != enemy1.Ypos && enemy3.Ypos != enemy2.Ypos) { combatLogic.targeting = true; targetCount = 3; } } if (enemyCount == 2) { if (PlayerPos.Ypos == enemy1.Ypos && enemy1.Ypos == enemy2.Ypos && enemy1.Xpos == Mathf.Min(enemy1.Xpos, enemy2.Xpos)) { combatLogic.targeting = true; targetCount = 1; } else if (PlayerPos.Ypos == enemy1.Ypos && enemy1.Ypos != enemy2.Ypos) { combatLogic.targeting = true; targetCount = 1; } else if (PlayerPos.Ypos == enemy2.Ypos && enemy2.Ypos == enemy1.Ypos && enemy2.Xpos == Mathf.Min(enemy1.Xpos, enemy2.Xpos)) { combatLogic.targeting = true; targetCount = 2; } else if (PlayerPos.Ypos == enemy2.Ypos && enemy2.Ypos != enemy1.Ypos) { combatLogic.targeting = true; targetCount = 2; } else { combatLogic.targeting = false; targetCount = 0; } } if (enemyCount == 1) { if (PlayerPos.Ypos == enemy1.Ypos) { combatLogic.targeting = true; targetCount = 1; } else { combatLogic.targeting = false; targetCount = 0; } } } if (targetCount > enemyCount) { targetCount = 0; combatLogic.targeting = false; } combatLogic.target = targetCount; }
// Callback for the movement ended on GridMovement, used to execute queued input protected virtual void Moved(GridMovement movement, GridTile fromGridPos, GridTile toGridPos) { _hasMoved = true; }
void Start() { PlayerPos = GameObject.FindGameObjectWithTag("Player").GetComponent <GridMovement>(); }
protected virtual void Awake() { m_MovementBlockers = GetComponents <MovementBlocker>().ToList(); _gridMovement = GetComponent <GridMovement>(); }
public void AddEnemy(GridMovement unit) { EnemyTeam.Add(unit); }
// Start is called before the first frame update void Start() { CurrentPos = this.GetComponent <GridMovement>(); }
public override void InitializeAgent() { m_RayPer = GetComponent <RayPerception>(); gridScript = GetComponent <GridMovement>(); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { movement = GetNode <GridMovement>("KenematicBody2D"); }
// Use this for initialization void Awake() { movement = GetComponent<GridMovement>(); aggroCollider.TriggerEntered = OnAggroTriggerEnter; hitCollider.TriggerEntered = OnHitTriggerEnter; }
public void AddDirection(GridPathNode node, int movementCost) { GridMovement gridMovement = new GridMovement(node, movementCost); directions[directionCount] = gridMovement; directionCount++; }
public void UpdatePlayerReference() { player = GameObject.FindGameObjectWithTag("Player"); playerLocation = player.GetComponent <GridMovement>(); }
// Use this for initialization void Start() { sprite1.SetActive(true); sprite2.SetActive(!sprite1.activeSelf); gridMovement = GameObject.FindObjectOfType <GridMovement>(); }
// Callback for the movement ended on GridMovement, used to execute queued input protected virtual void MovementEnded(GridMovement movement, GridTile fromGridPos, GridTile toGridPos) { ExecuteQueuedInput(); }
void Start() { movement = GetComponent <GridMovement> (); cloneAbility = GetComponent <CloneAbility> (); animator = GetComponent <Animator> (); }
private void Start() { gridMvmt = GameObject.Find("GridMovement"); characterList = gridMvmt.GetComponent <GridMovement>(); StartCoroutine("FOVRoutine"); }
protected virtual void Awake() { _gridObject = GetComponent <GridObject>(); _gridMovement = GetComponent <GridMovement>(); _intervalTimeLeft = m_UpdateInterval; }
void Start() { movement = GetComponent<GridMovement> (); cloneAbility = GetComponent<CloneAbility> (); animator = GetComponent<Animator> (); }
protected override void Start() { mover = GetComponent <GridMovement>(); base.Start(); healthBar.maxConcreteHPValue = maxHp; }
/// <summary> /// On Awake we grab our components /// </summary> protected virtual void Awake() { _gridMovement = GetComponent <GridMovement>(); _gridObject = GetComponent <GridObject>(); }
public IEnumerator ExecuteAllCards() { Debug.Log("Executing All Cards"); //get player objects //currently running the AI turns in an essentially random order. No bueno. List <GameObject> players = GameObject.FindGameObjectsWithTag("AI Player").ToList <GameObject>(); players.Add(GameObject.FindGameObjectWithTag("Player")); //get card list for each AI player //TODO: remove assumption that there's only one human player (players.count-1) List <List <GameObject> > hands = new List <List <GameObject> >(); for (int i = 0; i < players.Count - 1; i++) { hands.Add(cardSpawner.SpawnNCards_List(5)); } //get cards for human player, insist all cardslots are full GameObject[] cardSlots = GameObject.FindGameObjectsWithTag("CardSlot"); foreach (GameObject cardSlot in cardSlots) { if (cardSlot.transform.childCount == 0) { Debug.Log("PUT CARDS IN ALL THE SLOTS"); yield break; } } //get cards from cardslots List <GameObject> humanCards = new List <GameObject>(); foreach (var cardSlot in cardSlots) { humanCards.Add(cardSlot.transform.GetChild(0).gameObject); } hands.Add(humanCards); //ACTUALLY EXECUTING THE CARDS NOW //loop over card number for (int i = 0; i < 5; i++) { //loop over player for (int j = 0; j < hands.Count; j++) { GridMovement playerGridMovement = players[j].GetComponent <GridMovement>(); string action = hands[j][i].GetComponent <Card>().action; //todo: move this logic to gridmovement.cs Debug.Log(action); if (action == "forward" || action == "backward") { playerGridMovement.MoveDirectionRelative(action); } if (action == "left" || action == "right") { playerGridMovement.Turn(action); } yield return(new WaitForSeconds(TimeBetweenCards)); } } //end of movement checks foreach (GameObject player in players) { player.GetComponent <GridMovement>().CurrentNodeCheck_MovementEnd(); } //reset hand for new turn cardSpawner.DestroyAllCards(); cardSpawner.SpawnNCards(7); }
protected override void Start() { mover = GetComponent <GridMovement>(); base.Start(); }
void Start() { playerMovement = GetComponent<GridMovement> (); }
/// <summary> /// Adds a <see cref="HaushaltsRechner.Business.Mapper.GridMovement"/> /// </summary> /// <param name="movement"><see cref="HaushaltsRechner.Business.Mapper.GridMovement"/> to add</param> public void AddMovement(GridMovement movement) { _MovementsAmounts.Add(movement); CalcAmounts(); }
public void AddPlayer(GridMovement unit) { PlayerTeam.Add(unit); }
// Use this for initialization void Awake() { gm = GetComponent <GridMovement>(); smu = updater.GetComponent <SimultaneousUpdater>(); }
/// <summary> /// Removes a <see cref="HaushaltsRechner.Business.Mapper.GridMovement"/>. /// </summary> /// <param name="movement">The <see cref="HaushaltsRechner.Business.Mapper.GridMovement"/> to remove.</param> public void RemoveMovement(GridMovement movement) { _MovementsAmounts.Remove(movement); CalcAmounts(); }