Advertisement
Guest User

PlayerStatus.cs

a guest
Aug 26th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.48 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class PlayerStatus : MonoBehaviour {
  5.  
  6.     private bool inHideZone;
  7.     private bool isSneak;
  8.     private bool isCrawl;
  9.     private bool isRun;
  10.     private bool isIdle;
  11.     private bool isDie;
  12.     public string EnemyTag;
  13.    
  14.     // Use this for initialization
  15.     void Start () {
  16.         notInHideZone ();
  17.     }
  18.    
  19.     // Update is called once per frame
  20.     void Update () {
  21. //      Debug.Log ("Status Check, inHideZone: " + inHideZone + ", isSneak: " + isSneak +
  22. //          ", isCrawl:" + isCrawl + ", isRun:" + isRun + ", isIdle:" + isIdle);
  23.     }
  24.    
  25.     public void Taunt ()
  26.     {
  27.         bool guardCalled = false;
  28.         GameObject[] enemies;
  29.         enemies = GameObject.FindGameObjectsWithTag(EnemyTag);
  30.         Debug.Log (enemies.Length);
  31.         foreach (GameObject enemy in enemies)
  32.         {
  33.             if (enemy.GetComponent <EnermyAI> ().alertLevel == 1)
  34.             {
  35.                 if ((transform.position.x >= enemy.transform.position.x &&
  36.                     transform.position.x <= enemy.transform.position.x + enemy.GetComponent <EnermyAI> ().alertLevelOneSeeDistance) ||
  37.                     (transform.position.x <= enemy.transform.position.x &&
  38.                     transform.position.x >= enemy.transform.position.x - enemy.GetComponent <EnermyAI> ().alertLevelOneSeeDistance))
  39.                 {
  40.                     guardCalled = true;
  41.                     Debug.Log ("Tell: " + enemy.gameObject.name);
  42.                     enemy.GetComponent <EnermyAI> ().HearPlayer (transform.position.x);
  43.                 }
  44.             }
  45. //          else if (enemy.GetComponent <EnermyAI> ().alertLevel == 3)
  46. //          {
  47. //              if ((transform.position.x >= enemy.transform.position.x &&
  48. //                  transform.position.x <= enemy.transform.position.x + enemy.GetComponent <EnermyAI> ().alertLevelThreeSeeDistance) ||
  49. //                  (transform.position.x <= enemy.transform.position.x &&
  50. //                  transform.position.x >= enemy.transform.position.x - enemy.GetComponent <EnermyAI> ().alertLevelThreeSeeDistance))
  51. //              {
  52. //                 
  53. //              }  
  54. //          }
  55. //          else if (enemy.GetComponent <EnermyAI> ().alertLevel == 4)
  56. //          {
  57. //              if ((transform.position.x >= enemy.transform.position.x &&
  58. //                  transform.position.x <= enemy.transform.position.x + enemy.GetComponent <EnermyAI> ().alertLevelFourSeeDistance) ||
  59. //                  (transform.position.x <= enemy.transform.position.x &&
  60. //                  transform.position.x >= enemy.transform.position.x - enemy.GetComponent <EnermyAI> ().alertLevelFourSeeDistance))
  61. //              {
  62. //                 
  63. //              }  
  64. //          }
  65. //          else if (enemy.GetComponent <EnermyAI> ().alertLevel == 5)
  66. //          {
  67. //              if ((transform.position.x >= enemy.transform.position.x &&
  68. //                  transform.position.x <= enemy.transform.position.x + enemy.GetComponent <EnermyAI> ().alertLevelFiveSeeDistance) ||
  69. //                  (transform.position.x <= enemy.transform.position.x &&
  70. //                  transform.position.x >= enemy.transform.position.x - enemy.GetComponent <EnermyAI> ().alertLevelFiveSeeDistance))
  71. //              {
  72. //                 
  73. //              }  
  74. //          }
  75.         }
  76.         if (!guardCalled)
  77.         {
  78.             Debug.Log ("in");
  79.             GameObject enemyTmp = null;
  80.             float distance = 999999f;
  81.             foreach (GameObject enemy in enemies)
  82.             {
  83.                 if (enemy.GetComponent <EnermyAI> ().alertLevel != 1 &&
  84.                     enemy.GetComponent <EnermyAI> ().alertLevel != 2 &&
  85.                     distance >= (Mathf.Abs(transform.position.x - enemy.transform.position.x)))
  86.                 {
  87.                     enemyTmp = enemy;
  88.                     distance = Mathf.Abs(transform.position.x - enemy.transform.position.x);
  89.                 }
  90.             }
  91.             if (distance != 999999f)
  92.             {
  93.                 enemyTmp.GetComponent <EnermyAI> ().HearPlayer (transform.position.x); 
  94.             }
  95.         }
  96.     }
  97.    
  98.     public void isInHideZone ()
  99.     {
  100.         inHideZone = true; 
  101.     }
  102.    
  103.     public void notInHideZone ()
  104.     {
  105.         inHideZone = false;
  106.     }
  107.    
  108.     public bool ifInHideZone ()
  109.     {
  110.         return inHideZone; 
  111.     }
  112.    
  113.     public void isSneaking ()
  114.     {
  115.         isSneak = true;
  116.     }
  117.    
  118.     public void notSneaking ()
  119.     {
  120.         isSneak = false;
  121.     }
  122.    
  123.     public void isCrawling ()
  124.     {
  125.         isCrawl = true;
  126.     }
  127.    
  128.     public void notCrawling ()
  129.     {
  130.         isCrawl = false;   
  131.     }
  132.    
  133.     public void isRunning ()
  134.     {
  135.         isRun = true;  
  136.     }
  137.    
  138.     public void notRunning ()
  139.     {
  140.         isRun = false;
  141.     }
  142.    
  143.     public void isIdling ()
  144.     {
  145.         isIdle = true;
  146.     }
  147.    
  148.     public void notIdlling ()
  149.     {
  150.         isIdle = false;
  151.     }
  152.    
  153.     public void isDead ()
  154.     {
  155.         isDie = true;  
  156.     }
  157.    
  158.     public void notDead ()
  159.     {
  160.         isDie = false; 
  161.     }
  162.    
  163.     public bool ifSneaking ()
  164.     {
  165.         return isSneak;
  166.     }
  167.    
  168.     public bool ifCrawling ()
  169.     {
  170.         return isCrawl;
  171.     }
  172.    
  173.     public bool ifRunning ()
  174.     {
  175.         return isRun;  
  176.     }
  177.    
  178.     public bool ifIdlling ()
  179.     {
  180.         return isIdle; 
  181.     }
  182.    
  183.     public bool ifDead ()
  184.     {
  185.         return isDie;  
  186.     }
  187.    
  188.     public void ReceiveDamage ()
  189.     {
  190.         Debug.Log ("ReceiveDamage!!!");
  191.     }
  192. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement