public void Use(GamePadState gamePadState) { if (gamePadState.Buttons.X == ButtonState.Pressed) { if (useableObject != null) { if (useableObject.Use(this)) { useableObject = null; } } } }
public bool Use() { //Se lanza un rayo hacia delante, sumando cierta altura para no lanzarlo desde el suelo Ray usingRay = new Ray(this.transform.position + rayOffset, this.transform.forward); //Debug para poder visualizar el rayo en el inspector Debug.DrawLine(this.transform.position + rayOffset, this.transform.position + rayOffset + this.transform.forward * useDistance, Color.red); RaycastHit hit; if (Physics.Raycast(usingRay, out hit, useDistance)) { if (!hit.collider.isTrigger) { objectInUse = hit.collider.gameObject.GetComponent<UsableObject>(); if (objectInUse != null) { onCooldown = true; Invoke("ResetCooldown", useCooldown); //Se obtiene la normal del HIT para saber que parte del objeto ha encontrado el usable. //Solo se permite usar los objetos desde la parte de atras ( un angulo de 180 respecto al frente ) Vector3 normalLocal = hit.transform.TransformDirection(hit.normal); float angle = Vector3.Angle(hit.normal, hit.transform.forward); if (objectInUse.canUse) { objectInUse.Use(); if (objectInUse.type.Equals(UsableTypes.Hold)) { isUsing = true; if(objectInUse.usePosition!=null) { this.transform.position = objectInUse.usePosition.position; Vector3 look = objectInUse.transform.position; look.y = transform.position.y; this.transform.LookAt(look); } else { Vector3 frontPosition = hit.point + GetComponent<CapsuleCollider>().radius * hit.normal; Vector3 lookPosition = hit.point; lookPosition.y = transform.position.y; frontPosition.y = transform.position.y; this.transform.position = frontPosition; this.transform.LookAt(lookPosition); } } } } } } return isUsing; }
/// <summary> /// Recibe la notificacion de un objeto con su estado de activacion /// </summary> /// <param name="sender">Objeto notificador</param> /// <param name="status">estado de activacion del objeto</param> public override void NotifyChange(UsableObject sender, bool status) { usablesState[sender] = status; //Si todos los elementos estan activos, se resuelve el puzzle if(AnyActive()) { Solve(); } //Si el puzzle estaba resuelto, y algun elemento ha dejado de estar activo, se resetea else if(solved && type.Equals(puzzleType.Hold)) { Reset(); } }
void OnTriggerEnter2D(Collider2D otherObj) { if (otherObj.gameObject.tag == "Orb") { useableObject = otherObj.gameObject.GetComponent<Orb>(); useableObject.Use(this); useableObject = null; } else if (otherObj.gameObject.tag == "Shrine") { UsableObject shrine = otherObj.gameObject.GetComponent<Shrine>(); if (shrine == null) { shrine = otherObj.gameObject.GetComponent<EvilShrine>(); } useableObject = shrine; } }
public bool CanUse() { bool res = false; //Se lanza un rayo hacia delante, sumando cierta altura para no lanzarlo desde el suelo Ray usingRay = new Ray(this.transform.position + rayOffset, this.transform.forward); //Debug para poder visualizar el rayo en el inspector Debug.DrawLine(this.transform.position + rayOffset, this.transform.position + rayOffset + this.transform.forward * useDistance, Color.red); RaycastHit hit; if (Physics.Raycast(usingRay, out hit, useDistance)) { if (!hit.collider.isTrigger) { objectInUse = hit.collider.gameObject.GetComponent<UsableObject>(); if (objectInUse != null) { // Comprueba qeu siel personaje se encuentra en la zona correcta y el objeto no está en uso res = (objectInUse.canUse && !objectInUse.onUse); } } } return res; }
void OnTriggerExit2D(Collider2D otherObj) { if (otherObj.gameObject.tag == "Orb") { if (otherObj.gameObject.GetComponent<Orb>() == useableObject) { useableObject = null; } } else if (otherObj.gameObject.tag == "Shrine") { UsableObject shrine = otherObj.gameObject.GetComponent<Shrine>(); if (shrine == null) { shrine = otherObj.gameObject.GetComponent<EvilShrine>(); } if (shrine == useableObject) { useableObject = null; } } }
/// <summary> /// Detiene el uso del objeto /// </summary> public void StopUsing() { if (isUsing) { isUsing = false; objectInUse.CancelUse(); objectInUse = null; } }
/// <summary> /// Notifica la activacion de una de las campanas /// Comprueba que sea la campana corrspondiente al paso en la secuencia, o resetea el puzzle /// </summary> /// <param name="sender"></param> /// <param name="status"></param> public override void NotifyChange(UsableObject sender, bool status) { if (!playingSequence) { //((Bell)sender).Animation(); ((Bell)sender).PlaySound(); if (!solved) { if (status && seq[sequenceStep].Equals(sender)) { sequenceStep++; if (sequenceStep == seq.Length) { Solve(); } } else { Reset(); } } } }
/* CLEARING / REMOVING */ private void ClearObjectReferences(bool bDestroyUsedObject = false) { if (UsedObject != null) { // Make sure that the player does not have a 'UsedObject', and the object we previously used does not have a 'user' if (UsedObject.GetHasUser()) { UsedObject.User = null; } if (bDestroyUsedObject) Destroy(UsedObject.gameObject); UsedObject = null; } else { Debug.LogWarning("No used object to clear references from"); } }
/// <summary> /// Asigna el objeto de tipo 'Usable' que se puede activar con la habilidad en ese momento /// </summary> /// <param name="obj"></param> public void SetUsableObject(UsableObject obj) { usableObj = obj; }
public override bool SetReady(bool r, GameObject go = null, RaycastHit hitInfo = default(RaycastHit)) { ready = r; if (r) { usableObj = go.GetComponent<UsableObject>(); } return ready; }
// Use this for references void Awake() { charactersList = new List<CharacterStatus>(); usableObj = GetComponentInParent<UsableObject>(); }
private void Action_UsableObject_Use_OnActionEnd(UsableObject pUsableObject) { if (!pMouseHitthedObject.collider) { return; } float fObjectDistance = Vector3.Distance(vPlanPosition, pMouseHitthedObject.collider.transform.position); ////////////////////////////////////////////////////////////////////////////// // OBJECTS ON RANGE AND WITH USE AT STAGE END if (pUsableObject.tag == "Switcher") { // if a switcher( not plane ) is set ON_ACTION_END, pg will move to reach it if (fObjectDistance > (fUseDistance * 1.25f)) { Pathfinding pPathFinder = GLOBALS.PathFinder; // Calculate path pMouseHitthedObject.collider.gameObject.layer = LayerMask.NameToLayer("Default"); pPathFinder.UpdateGrid(); // remove this obstacle NodeList vNodes = new NodeList(); Vector3 vCoord = pPathFinder.NodeFromWorldPoint(pMouseHitthedObject.collider.gameObject.transform.position).worldPosition; bool bPathFound = pPathFinder.FindPath(vPlanPosition, vCoord, out vNodes); pMouseHitthedObject.collider.gameObject.layer = LayerMask.NameToLayer("Unwalkable"); pPathFinder.UpdateGrid(); // reset this obstacle // default is set to object position Vector3 vDestinationNode = pMouseHitthedObject.collider.gameObject.transform.position; if (bPathFound) { if (vNodes.Count > 1) { // If path node list contains more than one node, remove last one vNodes.RemoveRange(vNodes.Count - 1, 1); vDestinationNode = vNodes[vNodes.Count - 1].worldPosition; } else { vDestinationNode = vNodes[0].worldPosition; } } GLOBALS.StageManager.SetAction(new PlayerAction(vPlanPosition, vDestinationNode, pUsableObject), this.iID); } // this is a plane switcher else { GLOBALS.StageManager.SetAction(new PlayerAction(vPlanPosition, pUsableObject), this.iID); } this.Steps_Set(vPlanStageDestination = pMouseHitthedObject.collider.gameObject.transform.position); if (bPlanDebug) { Debug.Log("Movement to object set"); } return; } ////////////////////////////////////////////////////////////////////////////// // OBJECTS WITH USE AT DESTINATION REACHED { Vector3 vDestination = pMouseHitthedObject.collider.gameObject.transform.position; // Door has a proper point as destination if (pUsableObject.tag == "Door") { vDestination = pMouseHitthedObject.transform.GetChild(2).position; } this.Steps_Set(vPlanStageDestination = vDestination); GLOBALS.StageManager.SetAction(new PlayerAction(vPlanPosition, vDestination, pUsableObject), this.iID); if (bPlanDebug) { Debug.Log("Movement to object set"); } } }
/// <summary> /// Recibe la notificacion de un objeto con su estado de activacion /// </summary> /// <param name="sender">Objeto notificador</param> /// <param name="status">estado de activacion del objeto</param> public abstract void NotifyChange(UsableObject sender, bool status);
public void addResource(UsableObject resource, int quantity) { this.resourceList.Add(new Tuple <UsableObject, int>(resource, quantity)); }
////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// // Create as User /// <summary>Object use</summary> public PlayerAction(Vector3 _CurrentPosition, UsableObject _Object) { iType = ActionType.USE; vStartPoint = _CurrentPosition; pObject = _Object; }
public static void DrawNameAtTop(UsableObject obj) { topList.Add(obj); }
void handleOnUseFinished(GameObject sender) { levController.OnCustomAnimationFinished -= handleOnUseFinished; levController.turnToNormal(); heldUsable = null; }
public override void OnInspectorGUI() { gcScript = target as GunController; GUILayout.Space(10); if (gcScript.firePos == null) { GUILayout.Box("IMPORTANT! Assign a fire position before continuing!"); } gcScript.firePos = (Transform)EditorGUILayout.ObjectField("Fire Position:", gcScript.firePos, typeof(Transform), true); if (gcScript.firePos == null) { return; } gcScript.leftHandTransform = (Transform)EditorGUILayout.ObjectField("Left Hand:", gcScript.leftHandTransform, typeof(Transform), true); GUILayout.Space(5); if (GUILayout.Button("Convert To Pickup")) { PrefabUtility.DisconnectPrefabInstance(gcScript.gameObject); GunVisuals gv = gcScript.GetComponent <GunVisuals>(); if (gv) { foreach (GameObject go in gv.activateOnUse) { DestroyImmediate(go); } foreach (GameObject go in gv.deactivateOnUse) { go.SetActive(true); } DestroyImmediate(gcScript.firePos.gameObject); DestroyImmediate(gv); } PistolAnim pa = gcScript.GetComponent <PistolAnim>(); if (pa) { DestroyImmediate(pa); } gcScript.gameObject.AddComponent <Rigidbody>().mass = 3f; UsableObject uo = gcScript.gameObject.AddComponent <UsableObject>(); uo.weaponPickup = new UsableObject.WeaponPickup(); uo.weaponPickup.enabled = true; uo.weaponPickup.ammoAmount = gcScript.currentAmmo; uo.objectName = gcScript.gunName; uo.weaponPickup.weaponID = gcScript.weaponID; gcScript.transform.parent = null; gcScript.transform.name += " (Pickup)"; AntiClipVariables acv = gcScript.GetComponent <AntiClipVariables>(); if (acv) { DestroyImmediate(acv); } DestroyImmediate(gcScript); return; } if (GUILayout.Button("Reset IDs")) { WeaponDatabase.RefreshIDs(); return; } DarkRef.GUISeparator(); if (GUILayout.Button("Set First Person Info")) { GunController toSetFirst = WeaponDatabase.GetWeaponByID(gcScript.weaponID); toSetFirst.firstPersonPosition = gcScript.transform.localPosition; toSetFirst.firstPersonRotation = gcScript.transform.localRotation; gcScript.firstPersonPosition = gcScript.transform.localPosition; gcScript.firstPersonRotation = gcScript.transform.localRotation; } GUILayout.Label("First Person Info:", EditorStyles.boldLabel); GUILayout.Label(" Position: " + DarkRef.PreciseStringVector3(gcScript.firstPersonPosition)); GUILayout.Label(" Rotation: " + gcScript.firstPersonRotation.eulerAngles); DarkRef.GUISeparator(); if (GUILayout.Button("Set Third Person Info")) { GunController toSetThird = WeaponDatabase.GetWeaponByID(gcScript.weaponID); toSetThird.thirdPersonPosition = gcScript.transform.localPosition; toSetThird.thirdPersonRotation = gcScript.transform.localRotation; gcScript.thirdPersonPosition = gcScript.transform.localPosition; gcScript.thirdPersonRotation = gcScript.transform.localRotation; } if ((gcScript.transform.parent != null && gcScript.transform.parent.name == "WeaponsParent") && GUILayout.Button("Pose Transform")) { gcScript.transform.localPosition = gcScript.thirdPersonPosition; gcScript.transform.localRotation = gcScript.thirdPersonRotation; } GUILayout.Label("Third Person Info:", EditorStyles.boldLabel); GUILayout.Label(" Position: " + DarkRef.PreciseStringVector3(gcScript.thirdPersonPosition)); GUILayout.Label(" Rotation: " + gcScript.thirdPersonRotation.eulerAngles); DarkRef.GUISeparator(); GUILayout.Label("GUI Properties", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.BeginVertical(); gcScript.iconTexture = (Texture2D)EditorGUILayout.ObjectField("Icon:", gcScript.iconTexture, typeof(Texture2D)); gcScript.iconScale = EditorGUILayout.Vector2Field("Icon Scale:", gcScript.iconScale); gcScript.iconOffset = EditorGUILayout.Vector2Field("Icon Offset:", gcScript.iconOffset); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(10); gcScript.gunName = EditorGUILayout.TextField("Weapon Name:", gcScript.gunName); gcScript.weaponSlot = (WeaponSlot)EditorGUILayout.EnumPopup("Weapon Slot:", gcScript.weaponSlot); GUILayout.Space(5); GUILayout.Label("Fire Mode Settings", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.BeginVertical(); gcScript.firstMode = (GunController.FireMode)EditorGUILayout.EnumPopup("Fire Mode #1:", gcScript.firstMode); if (gcScript.firstMode != GunController.FireMode.None) { gcScript.firstRPM = EditorGUILayout.FloatField(" Fire Rate (RPM):", gcScript.firstRPM); } gcScript.secondMode = (GunController.FireMode)EditorGUILayout.EnumPopup("Fire Mode #2:", gcScript.secondMode); if (gcScript.secondMode != GunController.FireMode.None) { gcScript.secondRPM = EditorGUILayout.FloatField(" Fire Rate (RPM):", gcScript.secondRPM); GUI.enabled = false; } if (gcScript.secondMode == GunController.FireMode.None) { GUI.enabled = false; gcScript.thirdMode = GunController.FireMode.None; } else { GUI.enabled = true; } gcScript.thirdMode = (GunController.FireMode)EditorGUILayout.EnumPopup("Fire Mode #3:", gcScript.thirdMode); if (gcScript.thirdMode != GunController.FireMode.None && gcScript.secondMode != GunController.FireMode.None) { gcScript.thirdRPM = EditorGUILayout.FloatField(" Fire Rate (RPM):", gcScript.thirdRPM); } GUI.enabled = true; GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(5); BulletInfo.BulletType bulletType = gcScript.bulletInfo.bulletType; GUILayout.Label((bulletType == BulletInfo.BulletType.Bullet) ? "Bullet Properties" : "Projectile Properties", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.BeginVertical(); PoolingList poolList = (PoolingList)Resources.Load("Static Prefabs/PoolingList", typeof(PoolingList)); gcScript.bulletInfo.bulletType = (BulletInfo.BulletType)EditorGUILayout.EnumPopup("Bullet Type:", gcScript.bulletInfo.bulletType); GUI.color = new Color(1f, 0.8f, 0.8f); EditorGUILayout.ObjectField((bulletType == BulletInfo.BulletType.Bullet) ? "Bullet Prefab:" : "Projectile Prefab:", poolList.poolPrefabs[Mathf.Clamp(gcScript.bulletInfo.poolIndex, 0, poolList.poolPrefabs.Length - 1)], typeof(GameObject), true); GUI.color = Color.white; EditorGUI.indentLevel += 1; gcScript.bulletInfo.poolIndex = EditorGUILayout.IntField("Pool Index:", Mathf.Clamp(gcScript.bulletInfo.poolIndex, 0, poolList.poolPrefabs.Length - 1)); EditorGUI.indentLevel -= 1; GUILayout.Space(8f); gcScript.bulletInfo.damage = EditorGUILayout.IntField((bulletType == BulletInfo.BulletType.Rocket) ? "Explosion Damage" : "Damage:", gcScript.bulletInfo.damage); if (bulletType == BulletInfo.BulletType.Rocket) { gcScript.bulletInfo.explosionRadius = EditorGUILayout.FloatField("Explosion Radius:", gcScript.bulletInfo.explosionRadius); } else { gcScript.bulletInfo.force = EditorGUILayout.FloatField("Impact Force:", gcScript.bulletInfo.force); } gcScript.bulletInfo.muzzleVelocity = EditorGUILayout.FloatField("Base Velocity (m/s):", gcScript.bulletInfo.muzzleVelocity); gcScript.bulletInfo.gravityFactor = EditorGUILayout.Slider("Gravity (" + (-Physics.gravity.y * gcScript.bulletInfo.gravityFactor).ToString("F2") + " m/s)", gcScript.bulletInfo.gravityFactor, 0f, 5f); gcScript.bulletInfo.damageFalloff = EditorGUILayout.CurveField("Damage Falloff:", gcScript.bulletInfo.damageFalloff); for (int i = 0; i < gcScript.bulletInfo.damageFalloff.length; i++) { Keyframe modKey = gcScript.bulletInfo.damageFalloff.keys[i]; modKey.time = Mathf.RoundToInt(Mathf.Max(0f, modKey.time)); modKey.value = Mathf.Round(Mathf.Clamp(modKey.value, 0f, 1f) * 100f) / 100f; gcScript.bulletInfo.damageFalloff.MoveKey(i, modKey); } // if(gcScript.bulletInfo.penetrationDistance <= 0f) { gcScript.bulletInfo.ricochetLength = EditorGUILayout.IntField("Ricochet Amount:", Mathf.Max(gcScript.bulletInfo.ricochetLength, 0)); gcScript.bulletInfo.ricochetMaxAngle = EditorGUILayout.FloatField("Ricochet Max Angle:", Mathf.Clamp(gcScript.bulletInfo.ricochetMaxAngle, 0f, 90f)); /* * } * else { * EditorGUILayout.HelpBox("You must disable penetration to enable ricochet", MessageType.Info); * } * * gcScript.bulletInfo.penetrationDistance = EditorGUILayout.FloatField("Penetration Distance: ", Mathf.Clamp(gcScript.bulletInfo.penetrationDistance, 0f, 10000f)); * gcScript.bulletInfo.penetrationDamageReduction = EditorGUILayout.FloatField("Penetration Damage Reduction: ", Mathf.Clamp(gcScript.bulletInfo.penetrationDamageReduction, 0f, 100f)); * gcScript.bulletInfo.penetrationSpeedReduction = EditorGUILayout.FloatField("Penetration Speed Reduction: ", Mathf.Clamp(gcScript.bulletInfo.penetrationSpeedReduction, 0f, 100f)); */ GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.Label("Sound Settings", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.BeginVertical(); gcScript.fireSound = (AudioClip)EditorGUILayout.ObjectField("Fire Sound:", gcScript.fireSound, typeof(AudioClip), true); gcScript.emptySound = (AudioClip)EditorGUILayout.ObjectField("Empty Sound:", gcScript.emptySound, typeof(AudioClip), true); string reloadLabel = (gcScript.reloadMethod == GunController.ReloadMethod.Magazine) ? "Reload Sound:" : "Reload Sound (Loop):"; gcScript.reloadSound = (AudioClip)EditorGUILayout.ObjectField(reloadLabel, gcScript.reloadSound, typeof(AudioClip), true); if (gcScript.reloadMethod == GunController.ReloadMethod.Singular) { gcScript.reloadEnd = (AudioClip)EditorGUILayout.ObjectField("Reload End:", gcScript.reloadEnd, typeof(AudioClip), true); } else if (gcScript.reloadMethod == GunController.ReloadMethod.Magazine) { gcScript.reloadSoundEmpty = (AudioClip)EditorGUILayout.ObjectField("Reload Sound (empty):", gcScript.reloadSoundEmpty, typeof(AudioClip), true); } gcScript.switchSound = (AudioClip)EditorGUILayout.ObjectField("Switch Fire Mode:", gcScript.switchSound, typeof(AudioClip), true); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.Label("Shoot Settings", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.BeginVertical(); gcScript.bulletsPerShot = EditorGUILayout.IntSlider("Bullets Per Shot:", gcScript.bulletsPerShot, 1, 50); gcScript.countsAsOneBullet = EditorGUILayout.Toggle("Subtract 1 Bullet:", gcScript.countsAsOneBullet); if (gcScript.firstMode == GunController.FireMode.BurstFire || gcScript.secondMode == GunController.FireMode.BurstFire || gcScript.thirdMode == GunController.FireMode.BurstFire) { gcScript.bulletsPerBurst = EditorGUILayout.IntSlider("Rounds Per Burst:", gcScript.bulletsPerBurst, 2, Mathf.Max(3, gcScript.clipSize)); gcScript.burstInterval = EditorGUILayout.Slider("Burst Interval:", gcScript.burstInterval, 0.01f, 1f); gcScript.burstCooldown = EditorGUILayout.Slider("Burst Cooldown:", gcScript.burstCooldown, 0.01f, 1f); } GUILayout.Space(10); gcScript.muzzleProbability = EditorGUILayout.Slider("Muzzle Probability:", gcScript.muzzleProbability, 0f, 1f); gcScript.muzzleFlash = (ParticleEmitter)EditorGUILayout.ObjectField("Muzzle Flash:", gcScript.muzzleFlash, typeof(ParticleEmitter), true); gcScript.muzzleLight = (Light)EditorGUILayout.ObjectField("Muzzle Light:", gcScript.muzzleLight, typeof(Light), true); EditorGUI.indentLevel += 1; EditorGUIUtility.labelWidth = 140f; gcScript.muzzleSpeed = EditorGUILayout.FloatField("Light Fade Speed:", Mathf.Max(5f, gcScript.muzzleSpeed)); EditorGUIUtility.LookLikeControls(); EditorGUI.indentLevel -= 1; GUILayout.Space(5f); gcScript.shootParticle = (ParticleEmitter)EditorGUILayout.ObjectField("Shoot Smoke:", gcScript.shootParticle, typeof(ParticleEmitter), true); GUILayout.Space(10); gcScript.ejectionEnabled = EditorGUILayout.Toggle("Shell Ejection:", gcScript.ejectionEnabled); if (gcScript.ejectionEnabled) { gcScript.ejectionPos = (Transform)EditorGUILayout.ObjectField(" Ejection Position:", gcScript.ejectionPos, typeof(Transform), true); gcScript.bulletShellIndex = EditorGUILayout.IntField(" Bullet Shell Index:", gcScript.bulletShellIndex); gcScript.ejectionDelay = EditorGUILayout.FloatField(" Ejection Delay:", gcScript.ejectionDelay); gcScript.ejectionMinForce = EditorGUILayout.Vector3Field(" Minimum Force:", gcScript.ejectionMinForce); gcScript.ejectionMaxForce = EditorGUILayout.Vector3Field(" Maximum Force:", gcScript.ejectionMaxForce); gcScript.ejectionRotation = EditorGUILayout.FloatField(" Rotation Force:", gcScript.ejectionRotation); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.Label("Ammo Settings", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.BeginVertical(); gcScript.currentAmmo = EditorGUILayout.IntSlider("Current Ammo:", gcScript.currentAmmo, 0, gcScript.clipSize); gcScript.clipSize = EditorGUILayout.IntField(" Magazine Size:", gcScript.clipSize); GUILayout.Space(5f); gcScript.ammoLeft = EditorGUILayout.IntSlider("Reserve Ammo:", gcScript.ammoLeft, 0, gcScript.ammoLeftCap); gcScript.ammoLeftCap = EditorGUILayout.IntField(" Reserve Limit:", gcScript.ammoLeftCap); DarkRef.GUISeparator(7f); gcScript.reloadMethod = (GunController.ReloadMethod)EditorGUILayout.EnumPopup("Reload Method:", gcScript.reloadMethod); EditorGUI.indentLevel += 1; EditorGUIUtility.labelWidth = 140f; gcScript.reloadOnMouseClick = EditorGUILayout.Toggle("Reload On Click:", gcScript.reloadOnMouseClick); EditorGUIUtility.LookLikeControls(); if (gcScript.reloadMethod == GunController.ReloadMethod.Magazine) { EditorGUIUtility.labelWidth = 140f; gcScript.reloadLength = EditorGUILayout.FloatField("Reload Duration:", Mathf.Clamp(gcScript.reloadLength, 0f, 30f)); if (gcScript.reloadSoundEmpty != null) { gcScript.reloadLengthEmpty = EditorGUILayout.FloatField(" Empty Duration:", Mathf.Clamp(gcScript.reloadLengthEmpty, 0f, 30f)); } gcScript.includeChamberRound = EditorGUILayout.Toggle("Chamber Round:", gcScript.includeChamberRound); EditorGUIUtility.LookLikeControls(); } else if (gcScript.reloadMethod == GunController.ReloadMethod.Singular) { EditorGUIUtility.labelWidth = 135f; gcScript.reloadDelay = EditorGUILayout.FloatField("Reload Delay:", Mathf.Clamp(gcScript.reloadDelay, 0f, 5f)); gcScript.reloadInterval = EditorGUILayout.FloatField("Reload Interval:", Mathf.Clamp(gcScript.reloadInterval, 0f, 5f)); gcScript.reloadAmount = EditorGUILayout.IntField("Reload Amount:", Mathf.Clamp(gcScript.reloadAmount, 1, gcScript.clipSize)); GUILayout.Box("Reload sound will now loop, make sure that the sound can loop seamlessly."); EditorGUIUtility.LookLikeControls(); } EditorGUI.indentLevel -= 1; GUILayout.EndVertical(); GUILayout.EndHorizontal(); EditorGUIUtility.labelWidth = 165f; GUILayout.Space(5); GUILayout.Label("Aim Settings", EditorStyles.boldLabel); gcScript.sniperAimEffect = EditorGUILayout.Toggle(" Sniper Aim Effect:", gcScript.sniperAimEffect); gcScript.playerSpeedAim = EditorGUILayout.Slider(" Player Speed Aim:", gcScript.playerSpeedAim, 0.1f, 1f); gcScript.mouseSensitivityAim = EditorGUILayout.Slider(" Mouse Sensitivity Aim:", gcScript.mouseSensitivityAim, 0.01f, 1.0f); gcScript.aimPos = EditorGUILayout.Vector3Field(" Aim Position:", gcScript.aimPos); gcScript.aimSpeedFactor = EditorGUILayout.FloatField(" Aim Speed Factor:", gcScript.aimSpeedFactor); gcScript.addZoomFOV = EditorGUILayout.FloatField(" Additional Zoom (FOV):", Mathf.Clamp(gcScript.addZoomFOV, -15f, 75f)); gcScript.aimSwayFactor = EditorGUILayout.Slider(" Sniper Sway Factor:", gcScript.aimSwayFactor, 0f, 5f); GUILayout.Space(5); GUILayout.Label("Crosshair Settings", EditorStyles.boldLabel); gcScript.crosshairsEnabled = EditorGUILayout.Toggle(" Enabled:", gcScript.crosshairsEnabled); GUILayout.Space(5); GUILayout.Label("Accuracy and Recoil Settings", EditorStyles.boldLabel); gcScript.baseSpreadAmount = EditorGUILayout.FloatField(" Base Bullet Spread:", gcScript.baseSpreadAmount); gcScript.spreadSpeed = EditorGUILayout.FloatField(" Bullet Spread Speed:", gcScript.spreadSpeed); gcScript.spreadAimFactor = EditorGUILayout.Slider(" Spread Aim Factor:", gcScript.spreadAimFactor, 0f, 1f); gcScript.recoverSpeed = EditorGUILayout.FloatField(" Recover Spread Speed:", gcScript.recoverSpeed); gcScript.movementSpreadAmount = EditorGUILayout.FloatField(" Movement Spread Amount:", gcScript.movementSpreadAmount); gcScript.maxSpreadAmount = EditorGUILayout.FloatField(" Max Bullet Spread:", gcScript.maxSpreadAmount); gcScript.aimSpreadModifier = EditorGUILayout.Slider(" Aim Spread Mod:", gcScript.aimSpreadModifier, 0f, 1f); gcScript.crouchWalkModifier = EditorGUILayout.Slider(" Crouch/Walk Mod:", gcScript.crouchWalkModifier, 0f, 1f); GUILayout.Space(10); gcScript.recoilAmount = EditorGUILayout.FloatField(" Offset Recoil:", gcScript.recoilAmount); GUILayout.Space(6); gcScript.upKickAmount = EditorGUILayout.FloatField(" Up-kick Amount:", gcScript.upKickAmount); gcScript.autoReturn = EditorGUILayout.FloatField(" Auto Return:", gcScript.autoReturn); GUILayout.Space(5f); gcScript.sideKickAmount = EditorGUILayout.FloatField(" Side-kick Amount:", gcScript.sideKickAmount); gcScript.aimUpkickModifier = EditorGUILayout.Slider(" Aim Kick Modifier:", gcScript.aimUpkickModifier, 0f, 1f); gcScript.crouchUpkickModifier = EditorGUILayout.Slider(" Crouch Kick Modifier:", gcScript.crouchUpkickModifier, 0f, 1f); gcScript.kickInfluence = EditorGUILayout.Vector2Field(" Kick Influence", gcScript.kickInfluence); GUILayout.Space(5); EditorGUIUtility.LookLikeControls(200f); gcScript.extraRecoilThreshold = EditorGUILayout.IntField(" Extra Recoil Threshold:", gcScript.extraRecoilThreshold); gcScript.extraRecoilAmount = EditorGUILayout.FloatField(" Extra Recoil Amount (" + (gcScript.extraRecoilAmount * 100f).ToString() + "%):", Mathf.Max(0f, gcScript.extraRecoilAmount)); gcScript.maxExtraRecoil = EditorGUILayout.FloatField(" Extra Recoil Limit (+" + (gcScript.maxExtraRecoil * 100f).ToString() + "%):", Mathf.Max(0f, gcScript.maxExtraRecoil)); EditorGUIUtility.LookLikeControls(150f); GUILayout.Space(10f); gcScript.kickCameraTilt = EditorGUILayout.FloatField(" Camera Recoil Tilt:", gcScript.kickCameraTilt); gcScript.kickGunTilt = EditorGUILayout.FloatField(" Gun Recoil Tilt:", gcScript.kickGunTilt); gcScript.camShakeAnim = EditorGUILayout.FloatField(" Camera Animation:", gcScript.camShakeAnim); GUILayout.Space(5f); gcScript.kickBackAmount = EditorGUILayout.FloatField(" Kickback Amount:", gcScript.kickBackAmount); gcScript.kickSpeedFactor = EditorGUILayout.FloatField(" Kickback Speed:", gcScript.kickSpeedFactor); gcScript.kickbackAimFactor = EditorGUILayout.Slider(" Kickback Aim Factor:", gcScript.kickbackAimFactor, 0f, 1f); GUILayout.Space(5); GUILayout.Label("Animation Settings", EditorStyles.boldLabel); gcScript.reloadAnim = EditorGUILayout.TextField(" Reload Name:", gcScript.reloadAnim); GUILayout.Space(5); GUILayout.Label("Miscellaneous Settings", EditorStyles.boldLabel); gcScript.flashlight = (Light)EditorGUILayout.ObjectField(" Flashlight:", gcScript.flashlight, typeof(Light), true); gcScript.flashlightClick = (AudioClip)EditorGUILayout.ObjectField(" Flashlight Click:", gcScript.flashlightClick, typeof(AudioClip), true); GUILayout.Space(10f); gcScript.weaponWeight = EditorGUILayout.FloatField(" Weapon Weight (kg):", Mathf.Clamp(gcScript.weaponWeight, 0f, 100f)); gcScript.aimBobFactor = EditorGUILayout.Slider(" Aim Bob Factor:", gcScript.aimBobFactor, 0.01f, 1f); GUILayout.Space(10f); GUILayout.Label(" DoF Settings"); gcScript.dofBlurAmount = EditorGUILayout.FloatField(" Blur Amount:", Mathf.Clamp(gcScript.dofBlurAmount, 0f, 50f)); gcScript.dofBlurDistance = EditorGUILayout.FloatField(" Blur Distance:", Mathf.Clamp(gcScript.dofBlurDistance, 0f, 25f)); gcScript.dofBlurAperture = EditorGUILayout.FloatField(" Blur Aperture:", Mathf.Clamp(gcScript.dofBlurAperture, 0f, 40f)); gcScript.dofBlurFocalSize = EditorGUILayout.FloatField(" Focal Size:", Mathf.Clamp(gcScript.dofBlurFocalSize, 0f, 10f)); gcScript.dofBlendBlur = EditorGUILayout.FloatField(" Blend Blur:", Mathf.Clamp(gcScript.dofBlendBlur, 0f, 50f)); GUILayout.Space(10); gcScript.weaponID = EditorGUILayout.IntField("Weapon ID", Mathf.Clamp(gcScript.weaponID, -1, 2000)); if (GUI.changed) { EditorUtility.SetDirty(gcScript); } }
//////////////////////////////////////////////////////////////////////// ///////////////////////// PLAN MODE private void ParseInput() { // if ( EventSystem.current.IsPointerOverGameObject() ) return; if (GLOBALS.IsPaused) { return; } // Trace always mouse poited position bool pHitResult = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out pMouseHitthedObject); // Semi trasparent square sprite for current destination tile if (pHitResult) { SetPlainTile(); } // WAIT ACTION if (Input.GetMouseButtonDown(1)) { this.Action_Wait(); return; } // GOTO - USE ACTION if (Input.GetMouseButtonDown(0)) { if (pHitResult) { UsableObject pUsableObject = pMouseHitthedObject.collider.gameObject.GetComponent <UsableObject>(); string objTag = pMouseHitthedObject.collider.tag; if (pUsableObject) { // skip non usable objects if (pUsableObject.UseType == UsageType.NONE) { return; } // if ( objTag == "Key" || objTag == "Door" || objTag == "Switcher" || objTag == "Plane_Switcher" ) { ////////////////////////////////////////////////////////////////////////////// // INSTANT USE if (pUsableObject.UseType == UsageType.INSTANT) { this.Action_UsableObject_Use_Instant(pUsableObject); } ////////////////////////////////////////////////////////////////////////////// // ON ACTION END USE if (pUsableObject.UseType == UsageType.ON_ACTION_END) { this.Action_UsableObject_Use_OnActionEnd(pUsableObject); } // } } ////////////////////////////////////////////////////////////////////////////// // MOVEMENT ONLY if (objTag == "Tiles") { // player selection tutorial sprite if (GameManager.InTutorialSequence) { if (GameManager.TutorialStep == 1) { GLOBALS.GameManager.NextTutorial(); } // else return; // skip execution if is in tutorial mode } this.Action_MoveOnly(); } } } }
public void UseObject(UsableObject usable) { _idle = true; _usingObject = false; _currentIndexOfWay = 0; _someObject = usable; _wayToSomeObject = NavigationManager.Instance.FindWay(transform.position, _someObject.transform.position); }
public bool IsNPC() { bool res = false; //Se lanza un rayo hacia delante, sumando cierta altura para no lanzarlo desde el suelo Ray usingRay = new Ray(this.transform.position + rayOffset, this.transform.forward); //Debug para poder visualizar el rayo en el inspector Debug.DrawLine(this.transform.position + rayOffset, this.transform.position + rayOffset + this.transform.forward * useDistance, Color.red); // Comprueba si se trata de un NPC (Kodama o Tanuki) RaycastHit hit; if (Physics.Raycast(usingRay, out hit, useDistance)) { if (!hit.collider.isTrigger) { objectInUse = hit.collider.gameObject.GetComponent<Kodama>(); if (objectInUse == null) { objectInUse = hit.collider.gameObject.GetComponent<Tanuki>(); } if (objectInUse != null) { res = objectInUse.canUse; } } } return res; }
void Awake() { initiator = transform.Find("Initiator").GetComponent<UsableObject>(); }
public void AddUsable(UsableObject usableObject) { LevelManager.Instance.TreeObjects.Add(usableObject); }