// Use this for initialization void Start() { humanScript = GameObject.Find("HumanPlayer/Human").GetComponent(typeof(HumanController)) as HumanController; humanCam = GameObject.FindWithTag("humanCamera").GetComponent <Camera> (); humanCamScript = humanCam.GetComponent(typeof(CameraController)) as CameraController; ghostScript = GameObject.Find("GhostPlayer/Ghost").GetComponent(typeof(GhostController)) as GhostController; ghostCam = GameObject.FindWithTag("ghostCamera").GetComponent <Camera> (); ghostCamScript = ghostCam.GetComponent(typeof(CameraController)) as CameraController; playNum = (GameObject.Find("GameManager").GetComponent(typeof(GameController)) as GameController).getNumber(); humanLight = GameObject.Find("Lighting/HumanSkyLight"); ghostLight = GameObject.Find("Lighting/GhostSkyLight"); if (isLocalPlayer) { if (playNum == 1) { humanCam.enabled = true; humanLight.SetActive(true); ghostLight.SetActive(false); } else { ghostCam.enabled = true; ghostLight.SetActive(true); humanLight.SetActive(false); } } }
void TagGhost() { ActiveGhost = Hit.transform.gameObject; AG = ActiveGhost.GetComponent <GhostController>(); // GI = AG.gameObject.GetComponentInChildren<GhostInfo> (); PlaySoundEffect(); }
// Use this for initialization void Start() { kickstarting = true; ghost = gameObject.rigidbody2D; ghostController = GetComponent <GhostController>(); tileMap = tileMapCreator.GetComponent <TileMapFactory>().GetTileMap(); }
//Can we spawn the building in this location public bool CanSpawn(Coord newPosition) { //If we do not have a ghost object if (ghostObject.Count == 0 || ghostObject[0] == null) { return(false); } GhostController ghostC = ghostObject[0].GetComponent <GhostController>(); Coord buildingSize = ghostC.placementSize; //Make sure the bulding is fully on the map if ((newPosition.x - buildingSize.x) < 0 || (newPosition.y - buildingSize.y) < 0) { return(false); } //If the building is only on top of empty tiles for (int x = newPosition.x; x > (newPosition.x - buildingSize.x); x--) { for (int y = newPosition.y; y > (newPosition.y - buildingSize.y); y--) { if (!mapGrid.IsEmpty(new Coord(x, y))) { return(false); } } } return(true); }
//private Vector3 nextRespawnLocation; // Use this for initialization void Start() { rb = GetComponent <Rigidbody2D> (); GameObject cameraObject = GameObject.FindGameObjectWithTag("MainCamera"); myCamera = cameraObject.GetComponent <Camera> (); ghost = ghostObject.GetComponent <GhostController> (); controllerName = ""; getControllerName(); nextShot = 0.0f; currentHealth = maxHealth; blinkDamageAnimation = GetComponent <BlinkDamageAnimation> (); healthTracker = GetComponent <HealthTracker> (); healthTracker.startHealth(maxHealth); gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController> (); isDead = false; }
void Update() { if (Input.GetButtonDown ("1") && Ghosts[0]) { ActiveGhost = Ghosts[0]; AG = ActiveGhost.GetComponent<GhostController>(); PlaySoundEffect(); } else if (Input.GetButtonDown ("2") && Ghosts[1]) { ActiveGhost = Ghosts[1]; AG = ActiveGhost.GetComponent<GhostController>(); PlaySoundEffect(); } else if (Input.GetButtonDown ("3") && Ghosts[2]) { ActiveGhost = Ghosts[2]; AG = ActiveGhost.GetComponent<GhostController>(); PlaySoundEffect(); } else if (Input.GetButtonDown ("4") && Ghosts[3]) { ActiveGhost = Ghosts[3]; AG = ActiveGhost.GetComponent<GhostController>(); PlaySoundEffect(); } if (Input.GetButtonDown ("Action1")) { if (Physics.Raycast (Camera.main.ScreenPointToRay (Input.mousePosition), out Hit, 1000f)) { Debug.Log (Hit.transform.tag); if (Hit.transform.tag == "Ghost"){ TagGhost (); }else if (Hit.transform.tag == "Floor"){ TagFloor (); } } } }
// Use this for initialization void Start() { humanScript = human.GetComponent(typeof(HumanController)) as HumanController; ghostScript = ghost.GetComponent(typeof(GhostController)) as GhostController; Setup(); }
void TagGhost() { ActiveGhost = Hit.transform.gameObject; AG = ActiveGhost.GetComponent<GhostController>(); // GI = AG.gameObject.GetComponentInChildren<GhostInfo> (); PlaySoundEffect(); }
public IEnumerator Oscillate(GhostController ghost) { float progress = 0.5f; Vector3 top = new Vector3(ghost.transform.position.x, ghost.transform.position.y, ghost.transform.position.z + 0.5f); Vector3 bottom = new Vector3(ghost.transform.position.x, ghost.transform.position.y, ghost.transform.position.z - 0.5f); float speed = baseGhostSpeed / 2; while (!ghost.OscillationDone) { progress += speed * Time.deltaTime; Vector3 nextPos = Vector3.Lerp(top, bottom, TriangleWave(progress)); ghost.transform.LookAt(nextPos, Vector3.up); ghost.transform.position = nextPos; if (ghost.OscillationShouldFinish && progress - Mathf.Floor(progress) < 0.1f) { //Debug.Log("Oscillation done!"); ghost.OscillationDone = true; } yield return(null); } ghost.transform.position = new Vector3(ghost.transform.position.x, ghost.transform.position.y, 1); }
private void Assign(StartGameEvent e) { // Handle event here for (int i = 0; i < _players.Length; i++) { NPCController npcController = _players[i].GetComponent <NPCController>(); GhostController ghostController = _players[i].GetComponent <GhostController>(); HunterController hunterController = _players[i].GetComponent <HunterController>(); if (e.gameMode == GameMode.Practice) { hunterController.AlwaysRevealed = true; ghostController.AlwaysRevealed = true; } npcController.enabled = true; hunterController.enabled = false; ghostController.enabled = false; int minimumFurnitureCount = Mathf.Max(0, RoomManager.g.RoomCount - 1); int maximumFurnitureCount = RoomManager.g.RoomCount; npcController.InitFurniturePattern(RoomManager.g.RandomFurnitureList(Random.Range(minimumFurnitureCount, maximumFurnitureCount))); } int hunterIndex = Random.Range(0, _players.Length); int ghostIndex = Random.Range(0, _players.Length); if (ghostIndex == hunterIndex) { ghostIndex = (hunterIndex + 1) % _players.Length; } _players[hunterIndex].GetComponent <HunterController>().enabled = true; _players[ghostIndex].GetComponent <GhostController>().enabled = true; }
void OnTriggerEnter2D(Collider2D other) { PelletController _pellet = other.GetComponent <PelletController>(); if (_pellet != null) { GameDirector.Instance.IncreaseScore(_pellet.Value); GameDirector.Instance.PelletEaten(); Destroy(_pellet.gameObject); } PowerPelletController _powerPellet = other.GetComponent <PowerPelletController>(); if (_powerPellet != null) { GameDirector.Instance.ChangeGameState(GameDirector.States.enState_PacmanInvincible); Destroy(_powerPellet.gameObject); } GhostController _ghost = other.GetComponent <GhostController>(); if (_ghost != null) { // TODO: We are going to auto kill based off the Game Director needs to be resolved if (GameDirector.Instance.state == GameDirector.States.enState_Normal) { GameDirector.Instance.ChangeGameState(GameDirector.States.enState_GameOver); gameObject.SetActive(false); } else if (GameDirector.Instance.state == GameDirector.States.enState_PacmanInvincible) { _ghost.Kill(); } } }
public void ReturnToNormal() { coll.enabled = true; ghost.FinishPossess(); SetNormalColor(); ghost = null; }
public GhostController ClosestGhostToCharacter(CharacterMotor character) { Vector3 characterPos = character.transform.position; characterPos.y = 0f; GhostController closest = null; float sqrDistToClosest = Mathf.Infinity; foreach (CharacterMotor currNeighbor in _characters) { if (currNeighbor == character) { continue; } Vector3 currNeighborPos = currNeighbor.transform.position; currNeighborPos.y = 0f; float sqrDistToCurrNeighbor = (currNeighborPos - characterPos).sqrMagnitude; if (closest == null || sqrDistToCurrNeighbor < sqrDistToClosest) { sqrDistToClosest = sqrDistToCurrNeighbor; GhostController currNeighborGhostController = currNeighbor.GetComponent <GhostController>(); if (currNeighborGhostController != null) { closest = currNeighborGhostController.GetComponent <GhostController>(); } } } return(closest); }
public override void Reset() { chaseEvent = new ConcreteFsmEvent(); deathEvent = new ConcreteFsmEvent(); controller = owner.root.gameObject.GetComponent <GhostController>(); }
private void ResolveCollisionWithGhost(GameObject[] ghosts) { foreach (GameObject ghost in ghosts) { GhostController ghostController = ghost.GetComponent <GhostController>(); try { for (int i = 0; i < ghostController.points.Count; i++) //for every verlet point in ghost { Vector3 verletPoint = ghost.transform.TransformPoint(ghostController.points[i].current); //get point position in world coords float distance = (transform.position - verletPoint).magnitude; //distance from point to center of ball if (distance < ballController.radius) // then its inside the ball { // give velocity to that point verletPoint += transform.TransformDirection(ballController.translation); ghostController.points[i].current = ghost.transform.InverseTransformPoint(verletPoint); Destroy(gameObject); // destroys cannon ball return; } } } catch { } } }
//設置モード時のタイル表示処理 private void CheckSetUpColumns(Vector3Int startPos, Vector3Int originTilePos, GameObject gameObject) { Vector3Int startPoint = startPos; GhostController csGC = gameObject.GetComponent <GhostController>(); for (int y = 0; y < 2; y++) { for (int x = 0; x < 4; x++) { Vector3Int tempStartPoint = new Vector3Int(startPoint.x + x, startPoint.y - y, startPoint.z); if (csGC.isSelected == false /* && csGC.playerID!=PlayerTurn*/) { GhostController.playArea.SetTileFlags(tempStartPoint, TileFlags.None); //Set the colour. GhostController.playArea.SetColor(tempStartPoint, new Color(tileColor.r, tileColor.g, tileColor.b, 0.3f)); } if (csGC.isSelected == true /* && csGC.playerID == PlayerTurn*/) { if (tempStartPoint != originTilePos) { GhostController.playArea.SetTileFlags(tempStartPoint, TileFlags.None); //Set the colour. GhostController.playArea.SetColor(tempStartPoint, tileColor); } } } } }
void Spawn() { if (Time.time - lastDifficultyUpdate >= difficultyUpdateInterval) { difficultyUpdateInterval = Time.time; if (spawnInterval < maxSpawnInterval) { Debug.Log(spawnInterval); Debug.Log(difficultyRate); spawnInterval = spawnInterval / difficultyRate; } } GhostController ghostie = Instantiate(normghost) //Random.value < 0.5 ? normghost : wheelghost) .GetComponent <GhostController>(); ghostie.baseSpeed += 0.2f; if (ghostie.basePoseTime > 1.6) { ghostie.basePoseTime -= 0.1f; } ghostie.baseOuter -= 0.1f; ghostie.baseInner += 0.1f; Invoke("Spawn", spawnInterval); }
private void Awake() { this.IsPaused = true; this.ghostController = GetComponent <GhostController>(); this.photonView = GetComponent <PhotonView>(); //this.photonView = GetComponent<PhotonView>(); }
public void GetTarget(out int x, out int y, GhostController.ghostMode currentMode, GameController c) { switch (currentMode) { case GhostController.ghostMode.kChase: y = c.pacmanLoc.y / 8; x = c.pacmanLoc.x / 8; if (GhostController.Dist(x, y, c.clydeLoc.x / 8, c.clydeLoc.y / 8) < 8) { y = x = 0; } break; case GhostController.ghostMode.kScatter: y = 0; x = 0; break; case GhostController.ghostMode.kDead: x = 13; y = 21; break; case GhostController.ghostMode.kLeavingHouse: x = 13; y = 21; break; default: // no target x = y = 0; break; } }
void InitialStatus() { ghost = null; tmr = 0f; if (coll == null) { coll = GetComponent <BoxCollider>(); } coll.enabled = true; if (myMat == null) { Renderer r = GetComponent <Renderer>(); if (r == null) { spr = transform.GetChild(0).GetComponent <SpriteRenderer>(); myMat = spr.material; } else { myMat = GetComponent <Renderer>().material; } initialColor = myMat.color; } SetNormalColor(); }
public void StartPossessionInRoomForGhost(Room room, GhostController ghost) { if (CanPossess && !_catchingInProgress) { CharacterMotor character = ghost.GetComponent <CharacterMotor>(); GhostController closest = room.ClosestGhostToCharacter(character); if (closest == null) { Events.g.Raise(new PossessionEvent(false, room: null)); return; } Events.g.Raise(new PossessionEvent(true, room: room)); closest.enabled = true; ghost.enabled = false; _possessionCount++; _possessionChargeTimer.Stop(); _possessionChargeTimer.Reset(); _possessionForcedTimer.Stop(); _possessionForcedTimer.Reset(); StartPossessionCharge(); } else { Events.g.Raise(new PossessionEvent(false, room: null)); } }
void Start() { blinky = GameObject.Find("Blinky").GetComponent <GhostController>(); pinky = GameObject.Find("Pinky").GetComponent <GhostController>(); inky = GameObject.Find("Inky").GetComponent <GhostController>(); clyde = GameObject.Find("Clyde").GetComponent <GhostController>(); gameBoard = GameObject.Find("GameBoard").GetComponent <GameBoard>(); }
// Use this for initialization void Start() { ghostController = GetComponent <GhostController>(); ghostStateManager = ghostController.GetGhostStateManager(); bouncingUp = true; hasArrivedToCenter = false; }
public override void Reset() { scatterEvent = new ConcreteFsmEvent(); deathEvent = new ConcreteFsmEvent(); pacman = GameObject.FindObjectOfType <PacmanController>(); controller = owner.root.gameObject.GetComponent <GhostController>(); }
public override void EnterState(AI _owner) { Debug.Log("ENTERING SEARCH STATE"); ghost = _owner.ghost; totalSearchingTimer -= 0.25f; slowStats(); _owner.StopAndStare(); }
public override void EnterState(AI _owner) { Debug.Log("ENTERING FOLLOW STATE"); ghost = _owner.ghost; huntingTimer = 0f; speedBuff += _owner.speedStack + 0.35f; BuffStats(); }
void Awake() { _rigidbody = GetComponent <Rigidbody> (); _ghostController = GetComponent <GhostController> (); _hunterController = GetComponent <HunterController> (); _currRoomFinder = GetComponent <CurrRoomFinder> (); _transform = transform; }
public override void Reset() { chaseEvent = new ConcreteFsmEvent(); deathEvent = new ConcreteFsmEvent(); pacman = GameObject.FindObjectOfType <PacmanController>().transform; blinkyController = owner.root.gameObject.GetComponent <GhostController>(); }
float GetChasePowerPelletValue(GameController c, xyLoc closestPowerPellet) { if (powerUp) { return(0); } //return 1 - GetQuadraticCurveValue(GhostController.Dist(c.pacmanLoc, GetClosestGhostLoc(c)), .01f, 4); return(1 - GetLinearCurveValue(GhostController.Dist(new xyLoc(c.pacmanLoc.x / 8, c.pacmanLoc.y / 8), closestPowerPellet) * 4, .01f)); }
// Consumes the ghost reseting its fear status, sending it to prison, updating the score and starting FEAR modedisabling its Consumable aspect public override void IsConsumed() { UpdateScore(pointValue); GhostController ghost = gameObject.GetComponent <GhostController>(); ghost.ResetGhostFearState(false); ghost.GoToPrison(); gameObject.GetComponent <GhostConsumable>().enabled = false; }
// Start is called before the first frame update void Start() { if (mainAud) { mainAud.volume = 1.0f; } ghost = FindObjectOfType <GhostController>(); }
void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.CompareTag("Enemy")) { GhostController controller = col.gameObject.GetComponent <GhostController>(); controller.aiState = GhostAIState.SCATTER; col.gameObject.layer = 13; } }
public void Bounce(GhostController other) { float thisFrame = (other.transform.position - transform.position).magnitude ; float prevFrame = (other.GetPreviousPosition () - GetPreviousPosition () ).magnitude ; if ((thisFrame < prevFrame) && (currentNode != primeNode) && (lastNode != primeNode)) { PathNode temp = currentNode; currentNode = lastNode; lastNode = temp; } }
private void Awake() { instance = this; }
/** * */ public static void ReleaseGhost(GhostController ghost) { print ("ReleaseGhostReleaseGhostReleaseGhostReleaseGhost"); if (bKillingGhosts) return; Debug.Log("ReleaseGhost - Begin"); GameObject go = ghost.gameObject; if (ghost.nameLabel != null) { ReleaseUserNameLabel(ghost.nameLabel); ghost.setLabel(null); } // Delete hat // GameObject head = ghost.transform.FindChild("Head").gameObject; // if (head.transform.childCount > 0) // { // GameObject.Destroy(head.transform.GetChild(0).gameObject); // } go.SetActive(false); mGhosts.Add(go); mActiveGhosts.Remove(ghost); mActiveGhostMap.Remove( (int)ghost.DiesAtMeters ); Debug.Log("ReleaseGhost - End"); }