public void PickupObject(GameObject objectToPickup) { heldGameObject = objectToPickup; if (heldGameObject.GetComponent <ObjectState>().currentState == ObjectState.ObjectStates.Holstered) { // begin reloading a new gun in holster heldGameObject.GetComponentInParent <g_HolsterScript>().BeginRefresh(); } heldGameObject.GetComponent <ObjectState>().PickupObject(); //make our object's gameobject a child of our hand's mesh heldGameObject.transform.parent = TransformDeepChildExtension.FindDeepChild(transform, "Mesh"); for (int i = 0; i < Objects.Count; i++) { //go through our list of possible types of objects and find the one that //we currently have if (heldGameObject.GetComponent <ObjectState>().ID == Objects[i].ObjectID) { currentObject = Objects[i]; PlaySound(currentObject.pickupSound); } } //make the rigidbody kinematic so the gun doesn't fall down heldGameObject.GetComponent <Rigidbody>().isKinematic = true; handState = HandStates.Wielding; }
public void GunShoot() { var findGo = TransformDeepChildExtension.FindDeepChild(this.transform, "shootPoint").gameObject; //Debug.Log(findGo.name); var effectGo = Resources.Load <GameObject>("Prefab/Effect/GunEffect"); var effect = Instantiate(effectGo); effect.transform.position = findGo.transform.position; var bulletGo = Resources.Load <GameObject>("Prefab/Effect/Bullet1"); var bullet = Instantiate(bulletGo); bullet.transform.position = findGo.transform.position; var gunShootThrowing = bullet.AddComponent <GunShootThrowing>(); gunShootThrowing.GunThrow(bullet, monster); SoundEffectManager.instance.PlayAnimAudio(1); gunShootThrowing.throwAction = (targetMonster) => { if (findGo != null) { foreach (var mon in targetMonster) { //Debug.Log($"mon: {mon}"); } rangeMonstersAction(targetMonster); } }; }
void Start() { controller = GetComponent <Controller2D>(); thisCollider = GetComponent <Collider2D>(); animator = GetComponent <Animator>(); audioManager = GameObject.FindGameObjectWithTag("AudioManager").GetComponent <AudioManager>(); gm = GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster>(); cam = Camera.main; headBone = TransformDeepChildExtension.FindDeepChild(gameObject.transform, "HeadBone"); winCanvas = TransformDeepChildExtension.FindDeepChild(gameObject.transform, "WinCanvas").GetComponent <DeerWinCanvas>(); gravity = -155f; globalMaxInhabitRange = localMaxInhabitRange + transform.position; globalMinInhabitRange = localMinInhabitRange + transform.position; globalMaxSightRange = localMaxSightRange + transform.position; globalMinSightRange = localMinSightRange + transform.position; globalMaxFriendRange = localMaxFriendRange + transform.position; globalMinFriendRange = localMinFriendRange + transform.position; globalSpawnPoint = localSpawnPoint + transform.position; deerState = DeerState.grazing; faceDirX = -1; }
public void ActivateChildren() { for (int i = 0; i < names.Length; i++) { TransformDeepChildExtension.FindDeepChild(transform, names[i]).gameObject.SetActive(true); } }
void Start() { gm = GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster>(); audioManager = GameObject.FindGameObjectWithTag("AudioManager").GetComponent <AudioManager>(); controller = GetComponent <Controller2D>(); animator = GetComponent <Animator>(); gravity = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2); jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex; powerJumpVelocity = jumpVelocity * powerJumpMultiple; jumpsRemaining = maxJumps; attacksRemaining = maxAttacks; inputOnButtonPress = true; inputOnUIScreen = true; endLoadTime = Time.time; bow = TransformDeepChildExtension.FindDeepChild(gameObject.transform, "Bow"); bow.localScale = new Vector3(1 / gameObject.transform.lossyScale.x, 1 / gameObject.transform.lossyScale.y, 1 / gameObject.transform.lossyScale.z); midriffBone = TransformDeepChildExtension.FindDeepChild(gameObject.transform, "Midriff Bone"); faceDirX = 1; //StartCoroutine(LateStart(1.2f)); }
void Start() { footstepSound = GetComponent <AudioSource>(); controller = GetComponent <Controller2D>(); thisCollider = GetComponent <Collider2D>(); animator = GetComponent <Animator>(); audioManager = GameObject.FindGameObjectWithTag("AudioManager").GetComponent <AudioManager>(); cam = Camera.main; gm = GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster>(); footbone = TransformDeepChildExtension.FindDeepChild(gameObject.transform, "Front Foot"); bow = TransformDeepChildExtension.FindDeepChild(gameObject.transform, "Bow"); bow.localScale = new Vector3(1 / gameObject.transform.lossyScale.x, 1 / gameObject.transform.lossyScale.y, 1 / gameObject.transform.lossyScale.z); globalMaxInvestigateRange = localMaxInvestigateRange + transform.position; globalMinInvestigateRange = localMinInvestigateRange + transform.position; globalMaxPatrolRange = localMaxPatrolRange + transform.position; globalMinPatrolRange = localMinPatrolRange + transform.position; spiderWalkerState = SpiderWalkerState.patrolling; destPoint = globalMaxPatrolRange; patrolMovementState = PatrolMovementState.max; faceDirX = 1; }
private void SkinningVisibleUpperBody() { SkinnedMeshRenderer variableSkinnedMeshRendererSurfaceUpperBody; SkinnedMeshRenderer variableSkinnedMeshRendererJointsUpperBody; variableSkinnedMeshRendererSurfaceUpperBody = Instantiate(skinnedMeshRendererSurfaceUpperBody, this.transform); variableSkinnedMeshRendererJointsUpperBody = Instantiate(skinnedMeshRendererJointsUpperBody, this.transform); skinnedMeshRendererSurfaceUpperBody.enabled = false; skinnedMeshRendererJointsUpperBody.enabled = false; variableSkinnedMeshRendererSurfaceUpperBody.enabled = true; variableSkinnedMeshRendererJointsUpperBody.enabled = true; foreach (Transform tfm in skinnedMeshRendererSurfaceUpperBody.bones) { bonesCorrectOrder.Add(TransformDeepChildExtension.FindDeepChild(variableArmature, tfm.name)); } variableSkinnedMeshRendererSurfaceUpperBody.rootBone = variableArmature.GetChild(0).transform; variableSkinnedMeshRendererJointsUpperBody.rootBone = variableArmature.GetChild(0).transform; variableSkinnedMeshRendererSurfaceUpperBody.bones = bonesCorrectOrder.ToArray(); variableSkinnedMeshRendererJointsUpperBody.bones = bonesCorrectOrder.ToArray(); // EXPERIMENTAL // variableSkinnedMeshRendererSurfaceUpperBody.material = variableSkeletonMaterial; }
void OnTriggerExit(Collider other) { if (other.GetComponent <ObjectState>() != null) { GameObject tempObject = other.gameObject; TransformDeepChildExtension.FindDeepChild(tempObject.transform, "Image").GetComponent <GunUIScript>().SetInRange(gameObject, false); } }
void Start() { RotationObject = TransformDeepChildExtension.FindDeepChild(gameObject.transform, "RotationObject"); globalWaypoints = new Vector3[localWaypoints.Length]; for (int i = 0; i < localWaypoints.Length; i++) { globalWaypoints[i] = localWaypoints[i] + transform.position; } }
public bool Fire() { if (!canShootAgain) { return(false); } if (GetComponentInParent <handScript>().currentWeapon.ProjectilePrefab == null) { return(false); } firing = true; // when firing a single projectile per discharge (pistols, machineguns) // this loop will only run once. if firing several projectiles per // round (shotguns) the loop will iterate several times. the fire seed // is the same for every iteration, but is multiplied with the number // of iterations to get a unique, deterministic seed for each projectile. for (int v = 0; v < GetComponentInParent <handScript>().currentWeapon.ProjectileCount; v++) { if (GetComponent <GunAmmo>().currentAmmo > 0) { GameObject p = null; p = (GameObject)Instantiate(GetComponentInParent <handScript>().currentWeapon.ProjectilePrefab, FireTransform.position, FireTransform.rotation); if (TransformDeepChildExtension.FindDeepChild(transform, "FirePosition") != null) { //for the shotgun the bulletspawn rotation should change for each bullet based on spread if (p.GetComponent <g_ProjectileBullet>()) { p.GetComponent <g_ProjectileBullet>().damage = GetComponentInParent <handScript>().currentWeapon.damage; p.GetComponent <g_ProjectileBullet>().bulletSpawnTransform = TransformDeepChildExtension.FindDeepChild(transform, "FirePosition"); } else { p.transform.position = TransformDeepChildExtension.FindDeepChild(transform, "FirePosition").position; p.GetComponent <g_HitscanBullet>().Damage = GetComponentInParent <handScript>().currentWeapon.damage; } } GetComponent <GunAmmo>().currentAmmo--; } else { return(false); } } if (GetComponentInParent <handScript>().currentWeapon.MuzzleFlashPrefab != null) { ShowMuzzleFlash(); } canShootAgain = false; return(true); }
public void Flamethrow() { findGo = TransformDeepChildExtension.FindDeepChild(this.transform, "firePos").gameObject; var directionVector = this.transform.root.transform.rotation; var effectGo = Resources.Load <GameObject>("Prefab/Effect/FlameThrower"); var effect = Instantiate(effectGo); effect.transform.position = findGo.transform.position; effect.transform.rotation *= directionVector; var pos = findGo.transform.position; FlameRay(pos); }
void OnTriggerStay(Collider other) { //if radius trigger is hitting an object and we are not wielding anything if (other.GetComponent <ObjectState>() != null && heldGameObject == null) { GameObject tempObject = other.gameObject; TransformDeepChildExtension.FindDeepChild(tempObject.transform, "Image").GetComponent <GunUIScript>().SetInRange(gameObject, true); if (grabbing) { PickupObject(tempObject); } } }
public void ThunderShoot() { var findGo = TransformDeepChildExtension.FindDeepChild(this.transform, "thunderPos").gameObject; var effectGo = Resources.Load <GameObject>("Prefab/Effect/Thunder"); var effect = Instantiate(effectGo); effect.transform.position = findGo.transform.position; var thunderThrowing = effect.AddComponent <ThunderThrowing>(); thunderThrowing.ThunderThrow(effect, monster); thunderThrowing.throwAction = (targetMonster) => { rangeMonstersAction(targetMonster); }; }
void Start() { animator = gameObject.GetComponent <Animator>(); gm = GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster>(); menuSystem = GameObject.FindGameObjectWithTag("MenuSystem").GetComponent <MenuSystem>(); if (SceneManager.GetActiveScene().buildIndex != gm.levelPaddingBesidesMain) { RunTimeText = TransformDeepChildExtension.FindDeepChild(gameObject.transform, "RunTimeText").GetComponent <Text>(); BestTimeText = TransformDeepChildExtension.FindDeepChild(gameObject.transform, "BestTimeText").GetComponent <Text>(); RunTimeText.text = ""; BestTimeText.text = ""; } }
void Start() { FindPlayer(); controller = GetComponent <Controller2D>(); thisCollider = GetComponent <Collider2D>(); animator = GetComponent <Animator>(); audioManager = GameObject.FindGameObjectWithTag("AudioManager").GetComponent <AudioManager>(); cam = Camera.main; headBone = TransformDeepChildExtension.FindDeepChild(gameObject.transform, "HeadBone"); ravenState = RavenState.idle; faceDirX = -1; }
void AssignKey(string keyName) { switch (keyName) { case "left": GameMaster.gm.left = newKey; //Set forward to new keycode TransformDeepChildExtension.FindDeepChild(gameObject.transform, "SetLeftButton").GetComponentInChildren <Text>().text = GameMaster.gm.left.ToString(); //Set button text to new key PlayerPrefs.SetString("leftKey", GameMaster.gm.left.ToString()); //save new key to PlayerPrefs break; case "right": GameMaster.gm.right = newKey; //set backward to new keycode TransformDeepChildExtension.FindDeepChild(gameObject.transform, "SetRightButton").GetComponentInChildren <Text>().text = GameMaster.gm.right.ToString(); //set button text to new key PlayerPrefs.SetString("rightKey", GameMaster.gm.right.ToString()); //save new key to PlayerPrefs break; case "interact": GameMaster.gm.interact = newKey; //set left to new keycode TransformDeepChildExtension.FindDeepChild(gameObject.transform, "SetInteractButton").GetComponentInChildren <Text>().text = GameMaster.gm.interact.ToString(); //set button text to new key PlayerPrefs.SetString("interactKey", GameMaster.gm.interact.ToString()); //save new key to playerprefs break; case "useItem": GameMaster.gm.useItem = newKey; //set right to new keycode TransformDeepChildExtension.FindDeepChild(gameObject.transform, "SetUseItemButton").GetComponentInChildren <Text>().text = GameMaster.gm.useItem.ToString(); //set button text to new key PlayerPrefs.SetString("useItemKey", GameMaster.gm.useItem.ToString()); //save new key to playerprefs break; case "fireDash": GameMaster.gm.fireDash = newKey; //set jump to new keycode TransformDeepChildExtension.FindDeepChild(gameObject.transform, "SetDashFireButton").GetComponentInChildren <Text>().text = GameMaster.gm.fireDash.ToString(); //set button text to new key PlayerPrefs.SetString("fireDashKey", GameMaster.gm.fireDash.ToString()); //save new key to playerprefs break; case "jump": GameMaster.gm.jump = newKey; //set jump to new keycode TransformDeepChildExtension.FindDeepChild(gameObject.transform, "SetJumpButton").GetComponentInChildren <Text>().text = GameMaster.gm.jump.ToString(); //set button text to new key PlayerPrefs.SetString("jumpKey", GameMaster.gm.jump.ToString()); //save new key to playerprefs break; case "pause": GameMaster.gm.pause = newKey; //set jump to new keycode TransformDeepChildExtension.FindDeepChild(gameObject.transform, "SetPauseButton").GetComponentInChildren <Text>().text = GameMaster.gm.pause.ToString(); //set button text to new key PlayerPrefs.SetString("pauseKey", GameMaster.gm.pause.ToString()); //save new key to playerprefs break; } }
void Start() { controller = GetComponent <Controller2D>(); thisCollider = GetComponent <Collider2D>(); animator = GetComponent <Animator>(); audioManager = GameObject.FindGameObjectWithTag("AudioManager").GetComponent <AudioManager>(); cam = Camera.main; headBone = TransformDeepChildExtension.FindDeepChild(gameObject.transform, "HeadBone"); bow = TransformDeepChildExtension.FindDeepChild(gameObject.transform, "Bow"); balls = TransformDeepChildExtension.FindDeepChild(gameObject.transform, "Balls"); bow.localScale = new Vector3(1 / gameObject.transform.lossyScale.x, 1 / gameObject.transform.lossyScale.y, 1 / gameObject.transform.lossyScale.z); spiderShooterState = SpiderShooterState.inactive; faceDirX = 1; }
void Start() { foreach (string joint in trackedJoints) { // observedteacherKinectTs.Add(GameObject.Find(joint).transform); observedteacherKinectTs.Add(TransformDeepChildExtension.FindDeepChild(teacherKinectT, joint)); observedstudentKinectTs.Add(TransformDeepChildExtension.FindDeepChild(studentKinectT, joint)); } // foreach(Transform T in observedstudentKinectTs) // { // Debug.Log(T.parent.parent.name); // } model = ModelLoader.Load(kinectModel, false); worker = WorkerFactory.CreateWorker(WorkerFactory.Type.Compute, model); }
void Start() { bird1 = TransformDeepChildExtension.FindDeepChild(gameObject.transform, "bird1"); RotationObject = TransformDeepChildExtension.FindDeepChild(gameObject.transform, "RotationObject"); animator = GetComponent <Animator>(); animator.speed = 1 + Random.Range(-randomFlyingSpeedMult / 2f, randomFlyingSpeedMult / 2f); speed = speed * (1 + Random.Range(-randomFlyingSpeedMult / 2f, randomFlyingSpeedMult / 2f)); globalWaypoints = new Vector3[localWaypoints.Length]; for (int i = 0; i < localWaypoints.Length; i++) { globalWaypoints[i] = localWaypoints[i] + transform.position; } movementState = MovementState.flying; }
void Start() { animator = gameObject.GetComponent <Animator>(); gm = GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster>(); menuSystem = GameObject.FindGameObjectWithTag("MenuSystem").GetComponent <MenuSystem>(); deer = GetComponentInParent <Deer>(); startingTransform = transform.localScale; switchTransform = new Vector3(startingTransform.x * -1, startingTransform.y, startingTransform.z); if (SceneManager.GetActiveScene().buildIndex != gm.levelPaddingBesidesMain) { RunTimeText = TransformDeepChildExtension.FindDeepChild(gameObject.transform, "RunTimeText").GetComponent <Text>(); BestTimeText = TransformDeepChildExtension.FindDeepChild(gameObject.transform, "BestTimeText").GetComponent <Text>(); RunTimeText.text = ""; BestTimeText.text = ""; } }
public void KnifeShoot() { //TestCommander.OnAttack = (monster) => { // this.monster = monster; //}; var findGo = TransformDeepChildExtension.FindDeepChild(this.transform, "KnifePoint").gameObject; var effectGo = Resources.Load <GameObject>("Prefab/Effect/Knife"); var effect = Instantiate(effectGo); effect.transform.position = findGo.transform.position; var knifeThrowing = effect.AddComponent <KnifeThrowing>(); knifeThrowing.KnifeThrow(effect, monster); SoundEffectManager.instance.PlayAnimAudio(4); knifeThrowing.throwAction = (targetMonster) => { rangeMonstersAction(targetMonster); }; }
public void GasShoot() { var findWeapon = TransformDeepChildExtension.FindDeepChild(this.transform, "SA_Wep_Grenade").gameObject; findWeapon.SetActive(false); var findGo = TransformDeepChildExtension.FindDeepChild(this.transform, "GasPos").gameObject; var effectGo = Resources.Load <GameObject>("Prefab/Effect/GasBoomPrefab"); var effect = Instantiate(effectGo); effect.transform.position = findGo.transform.position; var GasThrowing = effect.AddComponent <GasThrowingLv2>(); if (monster != null) { //DanamateThrowing.DanamateThrow(effect, monster); GasThrowing.Shoot(effect, findGo.transform.position, monster, 9, 5); } GasThrowing.gasAction = (targetMonsters) => { dotDmgActionLv2(targetMonsters); }; }
public void ShortShoot1() { var findGo = TransformDeepChildExtension.FindDeepChild(this.transform, "ShortPoint1").gameObject; var effectGo = Resources.Load <GameObject>("Prefab/Effect/shortGunEffect"); var effect = Instantiate(effectGo); effect.transform.position = findGo.transform.position; var bulletGo = Resources.Load <GameObject>("Prefab/Effect/Bullet1"); var bullet = Instantiate(bulletGo); bullet.transform.position = findGo.transform.position; var gunShootThrowing = bullet.AddComponent <ShortThrowing>(); gunShootThrowing.GunThrow(bullet, monster); SoundEffectManager.instance.PlayAnimAudio(2); gunShootThrowing.shortGunAction = (targetMonster) => { if (targetMonster != null) { rangeMonstersAction(targetMonster); } }; }
public void DynamateShoot() { var findWeapon = TransformDeepChildExtension.FindDeepChild(this.transform, "SA_Wep_DynamiteBundle").gameObject; findWeapon.SetActive(false); var findGo = TransformDeepChildExtension.FindDeepChild(this.transform, "DanamatePos").gameObject; var effectGo = Resources.Load <GameObject>("Prefab/Effect/Dynamate"); var effect = Instantiate(effectGo); effect.transform.position = findGo.transform.position; var DanamateThrowing = effect.AddComponent <DynamiteThrowing3>(); if (monster != null) { //DanamateThrowing.DanamateThrow(effect, monster); DanamateThrowing.Shoot(effect, findGo.transform.position, monster, 9, 5); } DanamateThrowing.dynamiteAction = (targetMonsters) => { //Debug.Log("rangeMonstersAction"); rangeMonstersAction(targetMonsters); }; }
public void DeactivateChildren(int index) { TransformDeepChildExtension.FindDeepChild(transform, names[index]).gameObject.SetActive(false); }
public void SetActive() { var findGo = TransformDeepChildExtension.FindDeepChild(this.transform, "SA_Wep_Grenade").gameObject; findGo.SetActive(true); }
// Start is called before the first frame update void Start() { crownPH = TransformDeepChildExtension.FindDeepChild(this.transform, "PE_Crown").gameObject; }
void KillAI() { if (dead) { return; } dead = true; mesh.ChangeHologramColor(new Color(1, 0, 0)); GameObject.Find("Lights").GetComponent <g_LightManager>().ChangeToKillColour(); float score = GetComponent <scoreWorth> ().points; float timeToEnable = score / 2f; if (timeToEnable > 4f) { timeToEnable = 4f; } //needs to be a time limit if (animationScript) { animationScript.PlayDieAnimation(); } if (soundScript) { soundScript.PlayDeathSound(); Destroy(soundScript); } if (behaviourScript) { behaviourScript.enabled = false; } if (animationScript) { animationScript.enabled = false; } if (gunScript) { gunScript.enabled = false; } if (rotateScript) { rotateScript.enabled = false; } if (navmesh) { navmesh.enabled = false; } if (meleeScript) { meleeScript.enabled = false; } //Enable the ragdoll for (int i = 0; i < rigidbodies.Count; i++) { rigidbodies[i].isKinematic = false; } for (int i = 0; i < colliders.Count; i++) { Physics.IgnoreCollision(GameObject.Find("Player").GetComponent <Collider>(), colliders[i]); } if (animator) { animator.enabled = false; } if (m_gun) { m_gun.parent = null; m_gun.GetComponent <Rigidbody> ().isKinematic = false; m_gun.GetComponent <Collider> ().enabled = true; Destroy(m_gun.gameObject, 2f); } popUpScore.SetActive(true); popUpCombo.SetActive(true); GameObject.Find("Player").GetComponent <scoreTracker>().AddKill(GetComponent <scoreWorth>().points); GameObject.Find("Player").GetComponent <PlayerMoneyScript>().AddMoney(GetComponent <scoreWorth>().points); if (behaviourScript.m_coverTarget != null) { behaviourScript.m_coverTarget.GetComponent <g_CoverSpot>().taken = false; } if (GetComponent <g_AIID>().ID == 0) { GameObject.Find("CoverSpots").GetComponent <CoverManager>().AddCoverSpot(behaviourScript.m_coverTarget); } //GameObject.Find ("ScoreUI").GetComponent<enableOnTime> ().Enable (timeToEnable); if (onDeath == DeathStyles.dissolve) { // dissolveScript.Dissolve(); } else if (onDeath == DeathStyles.explode) { Instantiate(m_explosionEffect, transform.position + new Vector3(0, 1, 0), transform.rotation); TransformDeepChildExtension.FindDeepChild(transform, "Mesh").gameObject.SetActive(false); } if (GameObject.Find("Enemy Manager") != null) { GameObject.Find("Enemy Manager").GetComponent <EnemySpawner>().KillEnemy(gameObject); } Destroy(this); if (gameObject != null) { Destroy(gameObject, 2f); } }