/// <summary> /// constructor /// </summary> /// <param name="controller"></param> /// <param name="daughterType"></param> /// <param name="daughterSpawnCount"></param> public Mothership(NpcController controller, Ship daughterType, int daughterSpawnCount = 20) { Controller = controller; Mother = controller.Npc as Cubikon; DaughterType = daughterType; DaughterSpawnCount = daughterSpawnCount; }
public void Init(Transform trAim, Transform trPlayer, float minDis, float maxDis) { mAimTr = trAim; mPlayerTr = trPlayer; mDisMinVal = minDis; mDisMaxVal = maxDis; IsInit = true; if (IsTiShiQuan3D) { transform.parent = mAimTr; NpcController npcCtrl = trAim.GetComponent <NpcController>(); if (npcCtrl != null && npcCtrl.TiShiQuanTr != null) { transform.parent = npcCtrl.TiShiQuanTr; } else { PlayerController playerCtrl = trAim.GetComponent <PlayerController>(); if (playerCtrl != null && playerCtrl.TiShiQuanTr != null) { transform.parent = playerCtrl.TiShiQuanTr; } } transform.localPosition = Vector3.zero; } }
/// <summary> /// Function that gets called when customer leaves the counter. /// </summary> /// <param name="score">Score that customer gives to player</param> /// <param name="timeRatio">Ratio of time consumed to Maximum wait time of customer</param> /// <param name="playerIds">List of Player IDs that gets affected by this score</param> /// <param name="npcController">NPC controller that is controlling the NPC</param> private void customerLeft(float score, float timeRatio, List <Guid> playerIds, NpcController npcController) { if (playerIds.Count == 0) { // Customer left after time out case foreach (KeyValuePair <Guid, BasicController> entry in playersList) { pushScoreToPlayer(score, entry.Value); } } else if (score > 0) { // Successfully served case BasicController controller = playersList[playerIds[0]]; if (timeRatio <= 0.7f) { collectibleSpawner.spawnCollectible(playerIds[0]); } pushScoreToPlayer(score, controller); } else { // Failed with wrong combination,2x penalty foreach (Guid guid in playerIds) { BasicController controller = playersList[guid]; pushScoreToPlayer(2 * score, controller); } } }
public override void OnStart(NpcController c, bool instant = false) { base.OnStart(c); var chance = Random.value; if (chance < 0.2f) { GameManager.Singleton.AddHeart(2); c.HeartNum += 2; c._audio.PlayOneShot(c.Hint); Instantiate(GameManager.Singleton.HeartPrefab, c.transform.position + Vector3.up, Quaternion.identity); Instantiate(GameManager.Singleton.HeartPrefab, c.transform.position + Vector3.up * 1.5f, Quaternion.identity); } else if (chance > 0.2f && chance < 0.35f) { GameManager.Singleton.HeartNum--; c.HeartNum += 1; c._audio.PlayOneShot(c.Bad); Instantiate(GameManager.Singleton.BadHeartPrefab, c.transform.position + Vector3.up, Quaternion.identity); } else if (chance > 0.5f) { GameManager.Singleton.AddHeart(1); c.HeartNum += 1; c._audio.PlayOneShot(c.Hint); Instantiate(GameManager.Singleton.HeartPrefab, c.transform.position + Vector3.up, Quaternion.identity); } }
void Start() { if (NpcController.Singleton == null) { NpcController.Singleton = this; } else { Destroy(this); } AddState(new NState(NPCState.Idle)); AddState(new WalkState()); AddState(new AngryState()); AddState(new HurtState()); AddState(new AttackState()); AddState(new HiState()); AddState(new SadState()); AddState(new LeaveState()); rb.velocity = Vector3.zero; SetState(NPCState.Walk); WalkSpeed = 10f; DashSpeed = PlayerController.Singleton.DashSpeed; _renderer.flipX = true; _movement = -1; }
private void UpdateTargetInformation() { if (!NpcSensorSight.NpcsInSight.Any()) { CurrentEnemyTarget = null; } else if (CurrentEnemyTarget == null) { CurrentEnemyTarget = NpcSensorSight.GetClosestNpc(); } if (NpcSensorSight.PickablesInSight.Any() && CurrentMedicalKitTarget == null) { CurrentMedicalKitTarget = NpcSensorSight.GetClosestPickable(TypePickable.Medicalkit); } if (NpcSensorSight.PickablesInSight.Any() && CurrentShotgunTarget == null) { CurrentShotgunTarget = NpcSensorSight.GetClosestPickable(TypePickable.Shotgun); } if (NpcSensorSight.PickablesInSight.Any() && CurrentUziTarget == null) { CurrentUziTarget = NpcSensorSight.GetClosestPickable(TypePickable.Uzi); } UpdateCurrentEnemyDistance(); }
public void OnPickablePicked(NpcController npcController) { if (bonusEffect != null) { bonusEffect.ApplyBonusEffect(npcController); } }
private void NotifyNpcSightLost(NpcController npc) { if (OnNpcSightLost != null) { OnNpcSightLost(npc); } }
bool SpawnNPC(Color color) { List <Spawn> viableSpawns = new List <Spawn>(); foreach (Spawn s in spawns) { if (s.IsValid(reqDistance)) { viableSpawns.Add(s); } } if (viableSpawns.Count == 0) { return(false); } Spawn choice = viableSpawns[Random.Range(0, viableSpawns.Count)]; choice.Use(); NpcController newNPC = Instantiate(NpcPrefab, choice.transform.position, Quaternion.identity, NpcHolder.transform).GetComponent <NpcController>(); newNPC.color = color; newNPC.direction = choice.validDirections[Random.Range(0, choice.validDirections.Length)]; newNPC.UpdateAnim(); return(true); }
// Use this for initialization void Start() { units = new List <NpcController> (); var unitAvatar = Instantiate(unitTemplate); var charState = new CharState(); charState.SetBoredom(30); charState.SetFatigue(20); NpcController controller = new NpcController() { column = 2, row = 2, charSheet = new CharSheet(), charState = charState, questManager = new QuestManager(), avatar = unitAvatar }; controller.Start(); units.Add(controller); }
internal void BeginGame() { _GameWorld = _WorldCreationController.LevelOneLoad(); var vertices = new List <Vector2> { new Vector2(0, 500), new Vector2(50, 500), new Vector2(50, 550), new Vector2(0, 550) }; Body body = new Body(new Polygon(vertices), 1, 0); _Player = new CharacterController(new MapObject(TextureType.NotDrawn, body)); vertices = new List <Vector2> { new Vector2(750, 500), new Vector2(800, 500), new Vector2(800, 550), new Vector2(750, 550) }; body = new Body(new Polygon(vertices), 1, 0); _NpcCaveman = new CaveMan(new MapObject(TextureType.NotDrawn, body)); _NpcController = new NpcController(_WorldCreationController._NodeList, _WorldCreationController._PathList, _NpcCaveman); _GameWorld.Add(_Player._CharacterBody); _GameWorld.Add(_NpcCaveman._CaveManBody); }
// Update is called once per frame void Update() { if (inFlowChart) { return; } Vector3 move = new Vector3(Input.GetAxis("Horizontal"), 0); Vector3 newPosition = transform.position + (move * speed * Time.deltaTime); transform.position = newPosition; if (Input.GetAxis("Horizontal") > 0) { transform.localRotation = Quaternion.Euler(0, 180, 0); } else if (Input.GetAxis("Horizontal") < 0) { transform.localRotation = Quaternion.Euler(0, 0, 0); } if (interacting) { if (Input.GetKeyDown(KeyCode.UpArrow)) { NpcController npc = npcObject.GetComponent <NpcController>(); prepareFungusForConverstion(npc); clock.paused = true; npc.pausedPlayer(); talking = true; setInFlowChart(true); } } }
private void NotifyNpcSeen(NpcController npc) { if (OnNpcSeen != null) { OnNpcSeen(npc); } }
// Update is called once per frame void Update() { switch (AmmoState) { case AmmoType.GenZongDan: { float mvDis = AmmoSpeed * Time.deltaTime; if (Vector3.Distance(GenZongTr.position, transform.position) <= mvDis) { //子弹击中目标. NpcController npcCom = GenZongTr.GetComponent <NpcController>(); if (npcCom != null) { npcCom.OnDaoDanHit(transform.position); } OnDestroyThis(); return; } Vector3 vecForward = Vector3.Normalize(GenZongTr.position - transform.position); transform.position += vecForward * mvDis; transform.forward = Vector3.Lerp(transform.forward, vecForward, 15f * Time.deltaTime); break; } case AmmoType.YuLei: { CheckAmmoOverlapSphereHit(AmmoCoreTr); break; } } }
public void AddQuest(NpcController npcCont) { unlockRoom(npcCont.roomUnlockedOnBegin); Debug.Log(npcCont.roomUnlockedOnBegin + " unlocked!"); Debug.Log(npcCont.quest.location); Dictionary <string, Quest> tmp = new Dictionary <string, Quest>(); if (npcCont.quest != null) { tmp.Add(npcCont.quest.location, npcCont.quest); if (!inProgressQuests.ContainsKey(npcCont.quest.type)) { inProgressQuests.Add(npcCont.quest.type, tmp); } else { inProgressQuests[npcCont.quest.type].Add(npcCont.quest.location, npcCont.quest); } GameObject newQuest = Instantiate(npcCont.QuestGuiObject, new Vector3(0, 100 - (30 * (numberOfQuests() - 1)), 0), Quaternion.identity); newQuest.name = npcCont.quest.type + npcCont.quest.location; Debug.Log(menu); newQuest.transform.SetParent(menu.GetComponent <menuSwitch>().menu4.transform, false); newQuest.GetComponentInChildren <Text>().text = npcCont.quest.type + " in " + npcCont.quest.location + "! " + npcCont.quest.currentAmount + " out of " + npcCont.quest.goalAmount; } }
public Slave(NpcController controller, Character master) { Controller = controller; MasterCharacter = master; Controller.Npc.FactionId = master.FactionId; Controller.Npc.RefreshPlayersView(); }
public NpcController GetClosestNpc() { NpcController closestNpc = null; var distance = float.MaxValue; foreach (var npc in npcsInSight) { if (closestNpc == null) { closestNpc = npc; distance = Vector3.Distance(closestNpc.transform.position, transform.root.position); } else { var currentNpcDistance = Vector3.Distance(closestNpc.transform.position, npc.transform.position); if (distance > currentNpcDistance) { distance = currentNpcDistance; closestNpc = npc; } } } return(closestNpc); }
public void pausedPlayer() { //Text text = gameObject.GetComponentInChildren<Canvas>().GetComponentInChildren<Text>(); NpcController npc = gameObject.GetComponent <NpcController>(); npc.setDirection(NpcController.Direction.STANDING); //text.enabled = true; }
private void Awake() { uiController = GetComponent <UiController>(); boardController = GetComponent <BoardController>(); npcController = GetComponent <NpcController>(); sessionLogger = GetComponent <SessionLogger>(); sessionLogger.goldRewarded = (int)playerGoldCount; }
private void Awake() { npcController = GetComponent <NpcController>(); //fetch world controllers uiController = GetComponent <UiController>(); playerController = GetComponent <PlayerController>(); sessionLogger = GetComponent <SessionLogger>(); translator = GetComponent <Translator>(); }
public override void OnStart(NpcController c, bool instant = false) { base.OnStart(c, instant); if (instant) { WaitTime = 0.0f; } }
// 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) { controller = animator.transform.GetComponentInParent <NpcController>(); controller.navAgent.angularSpeed = 240; controller.navAgent.speed = controller.runSpeed; controller.navAgent.stoppingDistance = controller.combatRadius; }
public void destoryPerson(GameObject person) { NpcController npc = person.GetComponent <NpcController>(); updateAvailableList(npc.customerInfo); npcs.Remove(person); DestroyObject(person); }
private void CreateDetailedNpcCard(NpcController npcController) { var newDetailedNpcCard = Instantiate(detailedNpcCard); newDetailedNpcCard.GetComponentInChildren <UiNpcCardController>() .Configure(npcController); newDetailedNpcCard.transform.SetParent(transform); }
// Update is called once per frame void Update() { float x = Input.GetAxisRaw("Horizontal"); float y = Input.GetAxisRaw("Vertical"); float isMove = 0; Vector2 tempVector = new Vector2(x, y); if (tempVector.x != 0 || tempVector.y != 0) { lookDirection = tempVector; isMove = 1; } anim.SetFloat("moveX", lookDirection.x); anim.SetFloat("moveY", lookDirection.y); anim.SetFloat("speed", isMove); Vector2 position = rbody.position; //position.x += x*speed*Time.deltaTime; //position.y += y*speed*Time.deltaTime; position += tempVector * speed * Time.deltaTime; rbody.MovePosition(position); if (Input.GetKeyDown(KeyCode.J) && currentBulletNum > 0) { changeBulletNum(-1); GameObject bullet = Instantiate(bulletpreab, rbody.position, Quaternion.identity); BulletController bc = bullet.GetComponent <BulletController>(); if (bc != null) { bc.Move(lookDirection, 300); } AudioManager.instance.AudioPlay(launchclip); } if (Input.GetKeyDown(KeyCode.F)) { RaycastHit2D hit = Physics2D.Raycast(rbody.position, lookDirection, 2f, LayerMask.GetMask("NPC")); if (hit.collider != null) { NpcController nc = hit.collider.GetComponent <NpcController>(); if (nc != null) { nc.ShowDialog(); } Debug.Log("玩家与NPC交互"); } } //无敌倒计时 if (isInvisible) { invisibleTimer -= Time.deltaTime; if (invisibleTimer < 0) { isInvisible = false; } } }
void OnTriggerEnter2D(Collider2D other) { NpcController nc = other.gameObject.GetComponent <NpcController>(); if (nc != null) { nc.FoundWaypoint(); } }
private void OnTriggerExit(Collider other) { if (other.CompareTag("NPC")) { NpcController NPCAI = other.GetComponent <NpcController>(); NPCAI.GetComponent <NavMeshAgent>().speed /= speedFactor; SlowedNPC.Remove(NPCAI); } }
void initNPCController(GameObject person, int startingPosition) { NpcController npc = person.GetComponent <NpcController>(); npc.setId(spawnedNPCs); npc.customerInfo = availableCustomers[Random.Range(0, availableCustomers.Count)]; npc.setDirection(startingPosition < 0 ? NpcController.Direction.RIGHT : NpcController.Direction.LEFT); updateSpawnedList(npc.customerInfo); }
public override void interact(GameObject interactor) { BasicPawn pawn = interactor.GetComponent <BasicPawn>(); if (pawn.controller is NpcController) // If is NPC then set all data that customer is bringing in to counter. { resetData(); waitingController = (NpcController)pawn.controller; progressionBar.gameObject.SetActive(true); // Make controller stop waitingController.IsMobile = false; // Hard coded value to make npc go off screen after waiting waitingController.MoveTo = new Vector3(transform.parent.position.x, transform.parent.position.y + 7, waitingController.GetControlledPawn.transform.position.z); int itemMask = waitingController.attributes.salad; for (int i = 0; i < (int)Vegies.count; i++)// Using bit shifting to find ingredients. { if ((itemMask & 1) > 0) { int veg = (int)Mathf.Pow(2, i); VegetableData vegData = ChefSaladManager.getVegetableData(veg); scoreOnSuccess += vegData.Reward; penaltyOnFailure += vegData.Penalty; saladCanvas.addItem(vegData); } itemMask >>= 1; } scoreOnSuccess += scoreOnSuccess * waitingController.attributes.scoreMultiplier; penaltyOnFailure += waitingController.attributes.scoreMultiplier; } else //If it is player then get salad and do the processing. { Player player = (Player)pawn; int salad = player.PlayerInventory.getFirstItem(false) & (~(int)Vegies.oneItemSaladHandle); #if GAME_DEBUG Debug.Log("Player Serving salad " + salad + " Customer requested salad " + waitingController.attributes.salad); #endif if ((salad ^ waitingController.attributes.salad) == 0) // If salad ingredient match required ingredient do below { playerIds.Clear(); playerIds.Add(player.GetId); waitOver(scoreOnSuccess); } else // If not matching then add the player to player ids that needs to be affected by penalty. { playerIds.Add(player.GetId); if (timeMultiplier == 1)// Only increase time multiplier once rest of failure does not affect { timeMultiplier *= waitingController.attributes.failureTimeMultiplier; } } } }
private void GameDetailsSurvivor() { lastNpc = GameObject.FindGameObjectWithTag(Tags.Npc).GetComponentInChildren <NpcController>(); endGameDetails.text = TextSurvivorInfo + " "; endGameDetails.text += lastNpc.GetHealth(); endGameDetails.text += Environment.NewLine; endGameDetails.text += TextTimeTaken + " "; endGameDetails.text += timePassed; }
/* void sceneChanged(Notification notification) { npcs = GameObject.FindGameObjectsWithTag("TalkingNpc"); npcs = null; }*/ void playerWannaTalk(Notification notification) { if (npc != null) { string text; script = npc.gameObject.GetComponent("NpcController") as NpcController; text = script.getText(); if (text != "") { Variables.text=text; NotificationCenter.DefaultCenter().PostNotification(this, "drawText"); } else { NotificationCenter.DefaultCenter().PostNotification(this, "hideText"); } } }
protected virtual void Awake () { if (atributes.isHostile) { atributes.isQuestGiver = false; atributes.isEssential = false; atributes.hasDialouge = false; atributes.isMerchant = false; atributes.isSkillMaster = false; } if (atributes.isMerchant) atributes.isSkillMaster = false; controller = GameObject.Find ("GameController").GetComponent<GameController> (); actorControll = GetComponent<NpcController> (); CheckSetup (); }
private void Awake() { _playerCount = FindObject("PlayerCount").GetComponent<DigitDisplayManager>(); Debug.Log(FindObject("PlayerCount").tag); _timer = FindObject("TimerScreen").GetComponent<DigitDisplayManager>(); _npcController = FindObject("NpcController").GetComponent<NpcController>(); _playerController = FindObject("PlayerController").GetComponent<PlayerController>(); _themeAudioSource = FindObject("ThemeAudioSource").GetComponent<AudioSource>(); _playerController.TeamCount = PlayerPrefs.GetInt("TeamCount", 2); PlayerPrefs.DeleteAll(); AirConsole.instance.onConnect += OnConnect; _remainingTime = _timePerRound; }
// Use this for initialization void Start() { NotificationCenter.DefaultCenter().AddObserver(this, "hideText"); NotificationCenter.DefaultCenter().AddObserver(this, "BossDestroyed"); player = GeneralController.DefaultController().getPlayer(); playerAnim = player.GetComponent<Animator>(); playerController = player.GetComponent<PlayerController>(); lady = GameObject.Find("Ladyuvita"); ladyAnim = lady.GetComponent<Animator>(); ladyController = lady.GetComponent<NpcController>(); canvas = GameObject.Find("Canvas"); canvasAnim = canvas.GetComponent<Animator>(); shine = GameObject.Find("Shine"); shineAnim = shine.GetComponent<Animator>(); stopCinematic = true; //ladyAnim.SetBool("startAnim", true); // playerAnim.SetBool("startAnim", true); canvasAnim.SetBool("startAnim", true); playerFrom = new Vector3(0, -2.3f, 0); playerTo = new Vector3(0, -0.05f, 0); ladyFrom = new Vector3(0, 1.56f, 0); ladyTo = new Vector3(0, 0.25f, 0); time = Time.time; playerController.animated = true; playerAnim.SetInteger("direction", 1); playerAnim.SetBool("moving", true); ladyController.animated = true; ladyAnim.SetBool("moving", true); ladyAnim.SetInteger("direction", 3); lady.tag = "Npc"; bShine = false; isFinished=false; }