private void Start() { distanceToShoot = 1; distanceToAttract = 2; attractionForce = 0; level = transform.parent.GetComponent <NPCStats>(); }
// Creates an NPCInfo object with randomised statistics. public NPCInfo CreateNPCWithRandomizedStats() { NPCStats randomStats = GetRandomStats(); NPCAttributes randomNPC = SelectRandomNPC( FemaleCount++ > NumberOfFemales ? NPCAttributes.Gender.MALE : NPCAttributes.Gender.FEMALE ); NPCInfo npc = new NPCInfo() { Attributes = randomNPC, Stats = GetRandomStats() }; // Here we remove the npc from the available ones and stick it into // the temporary pool for hiring from. Npcs.Remove(randomNPC); AttributePool.Add(randomNPC); npc.Attributes.cost = CalculateEmployeeCost(npc); npc.Attributes.costThreshold = CalculateCostThreshold(npc); npc.Attributes.negotiationFrustration = 0; npc.Attributes.ammountPaidFor = 0; return(npc); }
// helper method to calculate the cost of employees based on their stats //TODO: and the player's current balance private int CalculateEmployeeCost(NPCInfo npc) { // work with float until the end where we will round float cost = 0; // each of the stats is worth an equal amount, and when added together must be within the // range of potential employee costs float minStatCost = MinEmployeeCost / 5f; float maxStatCost = MaxEmployeeCost / 5f; int npcCount = NPCController.Instance.NpcInstances.Count; float multiplier = (npcCount / 50f) + 1; minStatCost *= multiplier; maxStatCost *= multiplier; NPCStats stats = npc.Stats; cost += PercentBetween(minStatCost, maxStatCost, stats.Communication); cost += PercentBetween(minStatCost, maxStatCost, stats.Testing); cost += PercentBetween(minStatCost, maxStatCost, stats.Technical); cost += PercentBetween(minStatCost, maxStatCost, stats.Creativity); cost += PercentBetween(minStatCost, maxStatCost, stats.Design); if (npc.Attributes.gender.Equals(NPCAttributes.Gender.FEMALE)) { cost *= FemalePayMultiplier; } return(Mathf.RoundToInt(cost)); }
void Start() { movement = GetComponent <NPCMovement>(); stats = GetComponent <NPCStats>(); attackReady = true; }
public virtual void SetExecutingFSM(NPCStats _fsm) { if (_fsm != null) { fsm = _fsm; } }
//player enter pw by click btn public void EnterPW(string str, NPCStats ns) { //-1, because the program running sequence int i; i = ns.slotNum - 1; if (str == "Red") { pwInput.transform.GetChild(i).GetComponent <Image>().sprite = pwImgs[0]; ns.insertedList[i] = "Red"; } else if (str == "Green") { pwInput.transform.GetChild(i).GetComponent <Image>().sprite = pwImgs[1]; ns.insertedList[i] = "Green"; } else if (str == "Blue") { pwInput.transform.GetChild(i).GetComponent <Image>().sprite = pwImgs[2]; ns.insertedList[i] = "Blue"; } else if (str == "Black") { pwInput.transform.GetChild(i).GetComponent <Image>().sprite = pwImgs[3]; ns.insertedList[i] = "Black"; } else if (str == "White") { pwInput.transform.GetChild(i).GetComponent <Image>().sprite = pwImgs[4]; ns.insertedList[i] = "White"; } }
private void Awake() { // Check if Item is Randomly Generated if (IsRandom == true) { ID = Random.Range(1, 4); } npcInfo = Resources.Load(path + ID) as NPCStats; // Change stats name = npcInfo.name; Description = npcInfo.description; ID = npcInfo.ID; icon = npcInfo.icon; dialogue = npcInfo.dialogue; // load the Icon SpriteRenderer loadSprite = gameObject.GetComponent <SpriteRenderer>(); loadSprite.sprite = icon; // Give correct animation to enemy if (!testAni) { creatureAni = Resources.Load(pathAni + name) as AnimatorController; } if (!creatureAni) { Debug.LogError("Missing animation asset: " + pathAni + name + " could not be found."); } else { animator = GetComponent <Animator>(); animator.runtimeAnimatorController = creatureAni; } }
void Start() { //hp = NPCStats.Instance.hp; NPCStats npcStats = obj.GetComponent <NPCStats>(); hp = npcStats.hp; //hp = obj.gameObject.SendMessage("GetHp"); }
void AttackTarget() { NPCStats targetStats = currentTarget.GetComponent <NPCStats>(); targetStats.Explode(); stats.anim.SetTrigger("Land"); currentTarget = null; }
void Update() { NPCStats npcStats = obj.GetComponent <NPCStats>(); hp = npcStats.hp; //hp = NPCStats.Instance.hp; //hp = obj.gameObject.SendMessage("GetHp"); GetComponent <TextMesh>().text = hp.ToString(); }
//fixed position for npc to move; //type a&c will have two different pos for walk; //type b will have the same spot; //public GameObject pos1, pos2; // Use this for initialization void Start() { //targetGO = GameObject.FindGameObjectWithTag("Player"); agent = transform.GetComponent <NavMeshAgent>(); agent.updatePosition = false; agent.updateRotation = false; speed = 1.0f; anim = GetComponent <Animator>(); ns = GetComponent <NPCStats>(); targeted = false; }
private void Start() { rValue = 50f; ruin = false; regenTime = 30f; regenTimer = 0f; renderers = transform.GetComponentsInChildren <Renderer>(); if (guardian) { ns = guardian.GetComponent <NPCStats>(); } }
public void ShowPW(NPCStats ns) { //5 is current pw length, 6 is blank icon for (int i = 0; i < 5; i++) { if (ns.pwList[i] == "Red") { pwUI.transform.GetChild(i).GetComponent <Image>().sprite = pwImgs[0]; } else if (ns.pwList[i] == "Green") { pwUI.transform.GetChild(i).GetComponent <Image>().sprite = pwImgs[1]; } else if (ns.pwList[i] == "Blue") { pwUI.transform.GetChild(i).GetComponent <Image>().sprite = pwImgs[2]; } else if (ns.pwList[i] == "Black") { pwUI.transform.GetChild(i).GetComponent <Image>().sprite = pwImgs[3]; } else if (ns.pwList[i] == "White") { pwUI.transform.GetChild(i).GetComponent <Image>().sprite = pwImgs[4]; } //inserted pw list if (ns.insertedList[i] == "Red") { pwInput.transform.GetChild(i).GetComponent <Image>().sprite = pwImgs[0]; } else if (ns.insertedList[i] == "Green") { pwInput.transform.GetChild(i).GetComponent <Image>().sprite = pwImgs[1]; } else if (ns.insertedList[i] == "Blue") { pwInput.transform.GetChild(i).GetComponent <Image>().sprite = pwImgs[2]; } else if (ns.insertedList[i] == "Black") { pwInput.transform.GetChild(i).GetComponent <Image>().sprite = pwImgs[3]; } else if (ns.insertedList[i] == "White") { pwInput.transform.GetChild(i).GetComponent <Image>().sprite = pwImgs[4]; } else { pwInput.transform.GetChild(i).GetComponent <Image>().sprite = pwImgs[5]; } } }
public virtual void Consume(Object stats) { if (canHeal && (stats is Stats && canHeal || stats == null)) { Stats playerStats = GameObject.Find("Player").GetComponent <Stats>(); playerStats.Heal(healingAmount); } if (canHeal && stats is NPCStats && canHeal) { NPCStats npcStats = (NPCStats)stats; npcStats.Heal(healingAmount); } }
void Start() { combat = GetComponent <NPCCombat>(); stats = GetComponent <NPCStats>(); navAgent = GetComponent <NavMeshAgent>(); currentState = NPCState.PATROL; currentPatrolPoint = 0; attackStopDist = navAgent.stoppingDistance; //navAgent.stoppingDistance = attackRange / 2; }
// generates a stats object with all fields randomly initialized public NPCStats GetRandomStats() { NPCStats stats = new NPCStats { Communication = Random.Range(1, 101), Creativity = Random.Range(1, 101), Testing = Random.Range(1, 101), Technical = Random.Range(1, 101), Design = Random.Range(1, 101) }; return(stats); }
// Start is called before the first frame update void Start() { stats = (NPCStats)Resources.Load("NPC/Human"); Health = stats.Health; Hunger = stats.Hunger; Energy = stats.Energy; Thirst = stats.Thirst; Aggression = stats.Aggression; DexterityExp = stats.DexterityExp; EnduranceExp = stats.EnduranceExp; IntellectExp = stats.IntellectExp; StrengthExp = stats.StrengthExp; Id = ++GameState.instance.idCounter; }
public void SaveStats() { NPCStats save = new NPCStats(); //Debug.Log("Indx to save: " + majorConvoIndex); save.convoIndex = majorConvoIndex; //Debug.Log("Indx saved: " + save.convoIndex); BinaryFormatter format = new BinaryFormatter(); //Debug.Log(Application.persistentDataPath + savefile); FileStream fs = File.Create(Application.persistentDataPath + savefile); format.Serialize(fs, save); fs.Close(); Debug.Log(gameObject.name + " Stats Saved"); }
public bool LoadStats() { if (File.Exists(Application.persistentDataPath + savefile)) { BinaryFormatter format = new BinaryFormatter(); FileStream fs = File.Open(Application.persistentDataPath + savefile, FileMode.Open); NPCStats save = (NPCStats)format.Deserialize(fs); fs.Close(); //Debug.Log("Indx before: " + majorConvoIndex); majorConvoIndex = save.convoIndex; //Debug.Log("Indx after: " + majorConvoIndex); Debug.Log(gameObject.name + " stats loaded"); return(true); } return(false); }
private void CheckForHit() { RaycastHit[] hits = Physics.RaycastAll(new Ray(_prevPos, (transform.position - _prevPos).normalized), (transform.position - _prevPos).magnitude); for (int i = 0; i < hits.Length; i++) { Transform currHit = hits[i].collider.transform; bool target = currHit.root.tag.Contains("Target") || currHit.tag.Contains("Target"); bool pass = currHit.tag.Contains("Pass"); if (target && !pass) { String[] Tags = Regex.Split(currHit.tag + currHit.root.tag, @"(?<!^)(?=[A-Z])").Distinct().ToArray(); //Gets all tags split on upppercase foreach (String tag in Tags) { switch (tag) { case "Tank": TankStats tankStats = currHit.root.gameObject.GetComponent <TankStats>(); tankStats.triggerHit(gameObject); break; case "Object": ObjectStats objectStats = currHit.gameObject.GetComponent <ObjectStats>(); objectStats.TriggerHit(gameObject); break; case "Npc": NPCStats NPCStats = currHit.root.gameObject.GetComponent <NPCStats>(); NPCStats.TriggerHit(gameObject); break; } } Destroy(gameObject); return; } } }
void NPCHitBall(Collision2D other) { GameObject obj = other.gameObject; NPCStats level = obj.transform.parent.parent.GetComponent <NPCStats>(); float shootSpeed = level.shootSpeed; float yPaddlePos = obj.transform.position.y; float yBallPos = transform.position.y; float yVel; if (obj.GetComponent <Animator>().GetBool("Shoot")) { yVel = (Mathf.Abs(yBallPos - yPaddlePos) * shootSpeed * 1.75f); if (yBallPos < yPaddlePos) { yVel = -yVel; } float xVel = -shootSpeed; //Add force Vector3 pos = new Vector3(other.GetContact(0).point.x, other.GetContact(0).point.y); BallHitted(new Vector2(xVel, yVel), pos); Instantiate(ballHit, pos, Quaternion.identity); } }
// Use this for initialization void Start() { ns = transform.GetComponentInParent <NPCStats>(); rt = transform.GetComponent <RectTransform>(); }
//private GameObject dmgText; void Start() { Instance = this; }
public NPCDataSheet(NPCStats stats, NPCWeapon primaryWeapon, NPCWeapon secondWeapon) { NPCStats = stats; PriamaryWeapon = primaryWeapon; SecondaryWeapon = secondWeapon; }
// public abstract NPC_BehaviorState NextState(); protected virtual void Start() { npcController = GetComponent<NPC_Controller>(); npcAI = GetComponent<NPC_AI>(); npcStats = GetComponent<NPCStats>(); }
void OnTriggerEnter(Collider other) { if (!deflected && other.gameObject.CompareTag("Player")) { PlayerStats player = other.GetComponent <PlayerStats>(); if (!player.dead && !player.invuln) { Instantiate(bloodEffect, transform.position, bloodEffect.transform.rotation); LevelManager.instance.soundManager.PlayOneShot(hitClip); } player.TakeDamage(damage); trailRend.autodestruct = true; Destroy(gameObject); } else if (deflected && other.gameObject.CompareTag("Enemy")) { NPCStats enemy = other.GetComponent <NPCStats>(); if (!enemy.invuln) { if (enemy.currentHP > 0) { Instantiate(bloodEffect, transform.position, bloodEffect.transform.rotation); LevelManager.instance.soundManager.PlayOneShot(hitClip); } enemy.TakeDamage(damage); LevelManager.instance.player.stats.AddCombo(enemyHitCombo); LevelManager.instance.uiHandler.ComboBarAnim(); } trailRend.autodestruct = true; Destroy(gameObject); } else if (other.gameObject.CompareTag("Battery")) { HoloWall battery = other.GetComponentInParent <HoloWall>(); if (battery.batteryCurrentHp > 0) { Instantiate(batteryEffect, transform.position, batteryEffect.transform.rotation); LevelManager.instance.soundManager.PlayOneShot(hitClip); } battery.TakeDamage(damage); trailRend.autodestruct = true; Destroy(gameObject); } if (other.gameObject.CompareTag("ProjectileBoundary")) { trailRend.autodestruct = true; Destroy(gameObject); } }
public NormalHealth(NPCStats npcStats) { this.npcStats = npcStats; }