public override void OnInspectorGUI() { Aimer aimer = target as Aimer; /* * PrefabShooter shooter = aimer.GetComponent<PrefabShooter>(); * m_gunObject.Enabled = ((shooter == null) || !shooter.enabled); * m_gunObject.HelpText = m_gunObject.Enabled * ? "This is the object that will be aimed to point in the firing direction.\n" + * "If this is left blank, the parent GameObject will be used." * : "This field is currently disabled as the firing object is being set by the PrefabShooter also on this object.\n" + * "To change this field, either disable or remove the PrefabShooter from the gameobject."; */ Limiter limits = aimer.GetComponent <Limiter>(); m_applyToBarrel.Enabled = ((limits == null) || !limits.enabled); if (aimer.m_applyAimToBarrel && !m_applyToBarrel.Enabled) { #if UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 Undo.RegisterUndo(aimer, "Apply to barrel " + aimer.name); #else Undo.RecordObject(aimer, "Apply to barrel " + aimer.name); #endif aimer.m_applyAimToBarrel = false; } aimer.m_applyAimToBarrel &= m_applyToBarrel.Enabled; m_applyToBarrel.HelpText = m_applyToBarrel.Enabled ? "Whether or not apply the aim directly to the gun object" : "This field is currently disabled as it is being set by the AimerLimits component also on this object.\n" + "To change this field, wither disable or remove the AimerLimits from the gameobject."; m_applyToBarrel.FalseHelp = m_applyToBarrel.Enabled ? "FALSE: The gun object will not be aimed - it is up to the user (or another script) to access the AimDirection property to do the aiming." : ""; m_maxIterations.Enabled = ((aimer.m_targetType != Aimer.TargetPredictionType.Linear) || (aimer.m_projectileType != Aimer.ProjectilePredictionType.Linear)); m_maxIterations.HelpText = m_maxIterations.Enabled ? "The maximum number of iterations the solver will take to aim." : "This value is not used when both target and projectile predictor types are linear, as a faster analytic method is used to aim."; m_maximumInaccuracy.Enabled = m_maxIterations.Enabled; m_maximumInaccuracy.HelpText = m_maximumInaccuracy.Enabled ? "How close to the centre of the target the iterative solver has to get." : "This value is not used when both target and projectile predictor types are linear, as a faster analytic method is used to aim."; m_editHelp.EditProperties(aimer); if (Application.isPlaying) { bool enabled = GUI.enabled; GUI.enabled = false; EditorGUILayout.IntField("DEBUG: Iterations used", aimer.m_iterationsUsed); GUI.enabled = enabled; } }
// Update is called once per frame void Update() { p = controller.activePlayer; if (p.currentObj) { if (p.currentObj.GetComponent <HandCard>()) { if (p.currentObj.GetComponent <HandCard>().aimingBattlecry) { currentAction = "aimingbattlecry"; } else { currentAction = "playinghandcard"; } } else if (p.currentObj.GetComponent <BoardCharacter>()) { currentAction = "attacking"; } } else { currentAction = "none"; } if (p.currentObj != null) { if (currentAction == "playinghandcard") { Vector3 v3 = Input.mousePosition; v3 = Camera.main.ScreenToWorldPoint(v3); bool inBounds; if (p.playernum == 1) { inBounds = v3.y > -6 && v3.y < 0; } else { inBounds = v3.y > 0 && v3.y < 6; } if (inBounds) { if (p.board.Count > 0) { float cX = v3.x; int indx = 0; for (int i = 0; i < p.board.Count; i++) { if (p.board[i].transform.position.x < cX) { indx += 1; } } p.previewPos = indx; } else { p.previewPos = 0; } } } if (currentAction == "attacking") { target.GetComponent <SpriteRenderer>().enabled = true; Vector3 v3 = Input.mousePosition; v3 = Camera.main.ScreenToWorldPoint(v3); v3.z = -5; target.transform.position = new Vector3(v3.x, v3.y, v3.z); Cursor.visible = false; } if (currentAction == "aimingbattlecry") { target.GetComponent <SpriteRenderer>().enabled = true; Vector3 v3 = Input.mousePosition; v3 = Camera.main.ScreenToWorldPoint(v3); v3.z = -5; target.transform.position = new Vector3(v3.x, v3.y, v3.z); //Cursor.visible = false; } } else { Cursor.visible = true; target.GetComponent <SpriteRenderer>().enabled = false; p.previewPos = -1; } if (cheatsEnabled) { if (Input.GetKeyDown(KeyCode.D) == true) { p.draw(1); } if (Input.GetKeyDown(KeyCode.M) == true) { p.mMana += 1; } if (Input.GetKeyDown(KeyCode.C) == true) { p.cMana += 1; } if (Input.GetKeyDown(KeyCode.S) == true) { controller.nextTurn(); } } else { if (pos >= cheatCode.Length) { cheatsEnabled = true; } else if (Input.GetKeyDown(cheatCode[pos])) { pos++; } } }