Пример #1
0
    public IEnumerator SignAutograph()
    {
        CustomLogger.debug(this, "SignAutograph", CustomLogger.vipLog);
        m_Immune = true;
        m_NavAgent.Stop();
        List <Fan> fans = new List <Fan> (m_FansToSign);

        foreach (Fan fan in fans)
        {
            float waitTimer = 0.5f;
            while (waitTimer > 0)
            {
                waitTimer -= Time.deltaTime;
                AlignBody(fan.transform.position - this.transform.position, 360);
                yield return(new WaitForEndOfFrame());
            }
            m_FansToSign.Remove(fan);
            Destroy(fan.gameObject);
        }
        m_SignAutograph = null;
        //StopActions ();
        CustomLogger.debug(this, "remaining fan to sign = " + m_FansToSign.Count, CustomLogger.vipLog);
        if (m_FansToSign.Count > 0)
        {
            m_SignAutograph = StartCoroutine(SignAutograph());
        }
        else
        {
            m_NavAgent.Resume();
            m_Immune = false;
            //m_Walk = StartCoroutine (Walk ());
        }
    }
Пример #2
0
 public override void StopActions()
 {
     CustomLogger.debug(this, "stop actions", CustomLogger.guardLog);
     base.StopActions();
     m_Attack = null;
     m_Dash   = null;
 }
Пример #3
0
    // Attend et discute avec d'autres civils en attente si possible, sinon attente
    public void TryWaitAndChat()
    {
        CustomLogger.debug(this, "CheckWaitAndChat", CustomLogger.civilLog);
        List <Civil> listCivilWaiting = new List <Civil> ();
        Vector3      pointToLook      = this.transform.position;

        foreach (Civil civil in m_CivilNearby)
        {
            if (civil.GetCurrentBehavior() == "Wait")
            {
                listCivilWaiting.Add(civil);
                pointToLook += civil.transform.position;
            }
        }

        if (listCivilWaiting.Count > 0)
        {
            float chatDuration = Random.Range(5f, 10f);
            pointToLook = pointToLook / (listCivilWaiting.Count + 1);
            m_Wait      = this.StartCoroutine(WaitAndChat(chatDuration, pointToLook));
            foreach (Civil civil in listCivilWaiting)
            {
                civil.StartChatting(chatDuration, pointToLook);
            }
        }
        else
        {
            m_Wait = StartCoroutine(WaitAndLook());
        }
    }
Пример #4
0
    public void PushBack()
    {
        CustomLogger.debug(this, "PushBack", CustomLogger.guardLog);
        float            halfAttackAngle = 90;
        List <Transform> targets         = new List <Transform> ();

        foreach (Transform character in m_CharactersinRange)
        {
            if (character == null)
            {
                continue;
            }

            Vector3 lookDir = m_Body.forward;
            lookDir.y = 0;
            lookDir   = lookDir.normalized;
            Vector3 toTargetDir = (character.transform.position - this.transform.position);
            toTargetDir.y = 0;
            toTargetDir   = toTargetDir.normalized;
            float dotProd = Vector3.Dot(lookDir, toTargetDir);
            if (dotProd >= 0 && halfAttackAngle >= (90 - 90 * dotProd))
            {
                targets.Add(character);
            }
        }
        foreach (Transform target in targets)
        {
            CustomLogger.debug(this, "pushing : " + target.transform.name, CustomLogger.guardLog);
            if (target == null)
            {
                continue;
            }
            target.transform.GetComponent <IDamageable> ().PushBack(this.transform.position);
        }
    }
Пример #5
0
 public void ResumeGame()
 {
     CustomLogger.debug(this, "ResumeGame", CustomLogger.gameLog);
     m_EventSystem.SetSelectedGameObject(null);
     m_PausePanel.gameObject.SetActive(false);
     m_PauseMenuEnable = false;
     Time.timeScale    = 1;
 }
Пример #6
0
 public void DemandAutograph()
 {
     CustomLogger.debug(this, "DemandAutograph", CustomLogger.fanLog);
     m_Immune = true;
     Vip.Instance.AddFanToSign(this);
     m_Wait = StartCoroutine(WaitAutograph());
     GameManager.Instance.UpdateSerenityFame(m_CrisisPoints, m_FamePoints);
 }
Пример #7
0
 public void AddFanToSign(Fan fan)
 {
     CustomLogger.debug(this, "AddFanToSign (" + fan.transform.name + ")", CustomLogger.vipLog);
     m_FansToSign.Add(fan);
     if (m_SignAutograph == null)
     {
         //StopActions ();
         m_SignAutograph = StartCoroutine(SignAutograph());
     }
 }
Пример #8
0
    public IEnumerator WaitAutograph()
    {
        CustomLogger.debug(this, "WaitAutograph", CustomLogger.fanLog);
        Vector3 alignDir = Vip.Instance.transform.position - this.transform.position;

        while (true)
        {
            AlignBody(alignDir);
            yield return(new WaitForFixedUpdate());
        }
    }
Пример #9
0
 private void IncreaseFameLevel()
 {
     CustomLogger.debug(this, "IncreaseFameLevel", CustomLogger.gameLog);
     m_FameLevel++;
     m_FamePoints          = 0;
     m_SerenityPoints      = GameParameters.Instance.m_SerenityMax;
     m_ScoreMultiplicator *= GameParameters.Instance.m_ScoreMultiplicatorIncrease;
     GameParameters.Instance.IncreaseFameMax();
     GameParameters.Instance.IncreaseFanPerWave(m_FameLevel);
     UIManager.Instance.ResetFame(GameParameters.Instance.m_FameMax, m_FameLevel, m_ScoreMultiplicator);
 }
Пример #10
0
    public IEnumerator Attacking()
    {
        CustomLogger.debug(this, "Attacking", CustomLogger.guardLog);
        Vector3 spawnPos = this.transform.position + m_Body.forward;

        Instantiate(m_AttackPrefab, spawnPos, Quaternion.identity);

        yield return(new WaitForSeconds(0.2f));

        StopActions();
    }
Пример #11
0
 public void PauseGame(int playerID)
 {
     CustomLogger.debug(this, "PauseGame", CustomLogger.gameLog);
     Time.timeScale    = 0;
     m_PauseMenuEnable = true;
     m_PlayerPauseID   = playerID;
     m_PausePanel.gameObject.SetActive(true);
     m_ButtonSelectedNumber = 0;
     m_Buttons [m_ButtonSelectedNumber].Select();
     //StartCoroutine (MenuListener ());
 }
Пример #12
0
 public void ApplyDamage(int damages)
 {
     CustomLogger.debug(this, "ApplyDamage", CustomLogger.civilLog);
     if (m_TakingHit == null)
     {
         m_TakingHit = StartCoroutine(TakingHit());
     }
     else
     {
         CustomLogger.debug(this, "being hitting", CustomLogger.civilLog);
     }
 }
Пример #13
0
 public void PushBack(Vector3 bodyGuardPosition)
 {
     CustomLogger.debug(this, "PushBack", CustomLogger.fanLog);
     if (!m_Immune)
     {
         StartCoroutine(PushingBack(bodyGuardPosition));
     }
     else
     {
         CustomLogger.debug(this, "being push back", CustomLogger.fanLog);
     }
 }
Пример #14
0
 protected void OnTriggerExit(Collider collider)
 {
     CustomLogger.debug(this, "OnTriggerExit, collider = " + collider.transform.name, CustomLogger.guardLog);
     if (collider.transform.name == "Body" && collider.transform.parent.GetComponent <IDamageable> () != null)
     {
         Transform character = collider.transform.parent;
         if (character != null)
         {
             CustomLogger.debug(this, "removing character : " + character.name, CustomLogger.guardLog);
             m_CharactersinRange.Remove(character);
         }
     }
 }
Пример #15
0
    public IEnumerator Wait()
    {
        float waitTimer = Random.Range(m_WaitDurationMin, m_WaitDurationMax);

        CustomLogger.debug(this, "Wait (" + waitTimer + ")", CustomLogger.vipLog);
        while (waitTimer > 0)
        {
            waitTimer -= Time.deltaTime;
            yield return(new WaitForEndOfFrame());
        }
        StopActions();
        m_Walk = StartCoroutine(Walk());
    }
Пример #16
0
    // Attend et regarde un point d'interet (magazin, etc...)
    public IEnumerator WaitAndLook()
    {
        m_CurrentBehavior = "Wait";
        float waitTimer = Random.Range(2f, 5f);

        CustomLogger.debug(this, "WaitAndLook, " + waitTimer + " sec", CustomLogger.civilLog);
        while (waitTimer > 0)
        {
            waitTimer -= Time.deltaTime;
            yield return(new WaitForEndOfFrame());
        }
        StopActions();
        UpdateCivilAi();
    }
Пример #17
0
 public IEnumerator Walk()
 {
     CustomLogger.debug(this, "Walk", CustomLogger.fanLog);
     m_NavAgent.destination = Vip.Instance.transform.position;
     m_NavAgent.Resume();
     while (Vector3.Distance(Vip.Instance.transform.position, this.transform.position) >= m_VipInteractionDistance)
     {
         Vector3 goal = Vip.Instance.transform.position;
         goal.y = transform.position.y;
         m_NavAgent.destination = goal;
         AlignBody(m_NavAgent.velocity);
         yield return(new WaitForFixedUpdate());
     }
     StopActions();
     DemandAutograph();
 }
Пример #18
0
    // Attend et discute avec d'autres civils en attente
    public IEnumerator WaitAndChat(float duration, Vector3 pointToLook)
    {
        CustomLogger.debug(this, "WaitAndChat (" + duration + " sec / " + pointToLook + ")", CustomLogger.civilLog);
        m_CurrentBehavior = "Chat";

        float waitTimer = duration;

        while (waitTimer > 0)
        {
            waitTimer -= Time.deltaTime;
            AlignBody(pointToLook - transform.position);
            yield return(new WaitForEndOfFrame());
        }
        StopActions();
        UpdateCivilAi();
    }
Пример #19
0
 protected void SpawnCivils(int nbCivils)
 {
     for (int iter = 0; iter < nbCivils; iter++)
     {
         float      hiddenFanChance = Random.Range(0f, 100f);
         Vector3    SpawnPos        = ComputeRandomPointInLevel(30);
         GameObject civilInstance   = Instantiate(m_CivilPrefab, SpawnPos, Quaternion.identity) as GameObject;
         civilInstance.transform.SetParent(m_CivilParent);
         civilInstance.transform.name = "Civil" + m_CivilID.ToString();
         m_CivilID++;
         if (hiddenFanChance <= GameParameters.Instance.m_CivilFanProbability)
         {
             CustomLogger.debug(this, "hiddenFanChance = " + hiddenFanChance, CustomLogger.civilLog);
             civilInstance.GetComponent <Civil> ().SetHiddenFan(true);
         }
     }
 }
Пример #20
0
    public IEnumerator PushingBack(Vector3 bodyGuardPosition)
    {
        CustomLogger.debug(this, "PushingBack", CustomLogger.fanLog);
        m_NavAgent.Stop();
        float   pushDuration = 0.2f;
        Vector3 pushDir      = (transform.position - bodyGuardPosition).normalized;

        while (pushDuration > 0)
        {
            Vector3 moveVector = pushDir * 20 * Time.fixedDeltaTime;
            m_NavAgent.Move(moveVector);
            pushDuration -= Time.deltaTime;
            yield return(new WaitForEndOfFrame());
        }
        m_NavAgent.Resume();
        CustomLogger.debug(this, "PushingBack End", CustomLogger.fanLog);
    }
Пример #21
0
    public void SpawnFanWave()
    {
        //int spawnerNumber = Random.Range(0,m_FanSpawners.Count);
        CustomLogger.debug(this, "SpawnFanWave", CustomLogger.spawnerLog);
        //Transform spawner = m_FanSpawners[spawnerNumber];
        int nbFans = Random.Range(GameParameters.Instance.m_FanMinPerWave, GameParameters.Instance.m_FanMaxPerWave + 1);

        for (int iter = 0; iter < nbFans; iter++)
        {
            int        spawnerNumber = Random.Range(0, m_FanSpawners.Count);
            Transform  spawner       = m_FanSpawners[spawnerNumber];
            Vector3    spawnPos      = ComputeRandomPointNextToSpawner(spawner.position, 5);
            GameObject fanInstance   = Instantiate(m_FanPrefab, spawnPos, Quaternion.identity) as GameObject;
            fanInstance.transform.SetParent(m_FanParent);
            fanInstance.transform.name = "Fan" + m_FanID.ToString();
            m_FanID++;
        }
    }
Пример #22
0
    public IEnumerator FanTransformation()
    {
        CustomLogger.debug(this, "FanTransformation", CustomLogger.civilLog);
        m_CurrentBehavior = "Transformation";

        float waitTimer = 2;

        while (waitTimer > 0)
        {
            waitTimer -= Time.deltaTime;
            AlignBody(Vip.Instance.transform.position - this.transform.position);
            transform.localScale = Vector3.one + Vector3.one * 0.5f * Mathf.Pow(Mathf.Cos(waitTimer * 3), 2);
            yield return(new WaitForEndOfFrame());
        }
        StopActions();
        SpawnManager.Instance.SpawnFan(transform.position, m_Body.rotation);
        SpawnManager.Instance.RespawnCivils(1);
        Destroy(this.gameObject);
    }
Пример #23
0
    // Marche vers un point d'interet (magasin, etc...)
    public IEnumerator WalkToInterestPoint()
    {
        CustomLogger.debug(this, "WalkToInterestPoint", CustomLogger.civilLog);
        m_CurrentBehavior = "Walk";
        Vector3 goal = ComputeInterestPoint(30);

        m_NavAgent.ResetPath();
        m_NavAgent.SetDestination(goal);
        m_NavAgent.Resume();
        while (Vector3.Distance(this.transform.position, goal) > 1f)
        {
            AlignBody(m_NavAgent.velocity);
            yield return(new WaitForFixedUpdate());
        }
        StopActions();
        m_NumberOfMove--;
        CustomLogger.debug(this, "number of move remaining = " + m_NumberOfMove, CustomLogger.civilLog);
        TryWaitAndChat();
    }
Пример #24
0
    public IEnumerator Dying()
    {
        CustomLogger.debug(this, "Dying", CustomLogger.fanLog);
        GameManager.Instance.IncreaseScore(m_ScorePoints);
        m_Immune = true;
        float    deathDuration = 0.5f;
        Material matBody       = m_Body.GetComponent <MeshRenderer> ().materials [0];
        Material matHead       = m_Head.GetComponent <MeshRenderer> ().materials [0];

        matBody.color = new Color(1, 0, 0, 1);
        matHead.color = new Color(1, 0, 0, 1);
        while (transform.localScale.x > 0)
        {
            Vector3 newScale = transform.localScale;
            newScale            -= Vector3.one * Time.deltaTime / deathDuration;
            transform.localScale = newScale;
            yield return(new WaitForEndOfFrame());
        }
        Destroy(this.gameObject);
    }
Пример #25
0
    public void RespawnCivils(int numberToSpawn)
    {
        int       rand    = Random.Range(0, m_CivilSpawners.Count);
        Transform spawner = m_CivilSpawners [rand];

        CustomLogger.debug(this, "Spawnin Civil" + m_CivilID.ToString() + " from : " + spawner.name, CustomLogger.spawnerLog);
        for (int iter = 0; iter < numberToSpawn; iter++)
        {
            float      hiddenFanChance = Random.Range(0f, 100f);
            Vector3    SpawnPos        = ComputeRandomPointNextToSpawner(spawner.position, 5);
            GameObject civilInstance   = Instantiate(m_CivilPrefab, SpawnPos, Quaternion.identity) as GameObject;
            civilInstance.transform.SetParent(m_CivilParent);
            civilInstance.transform.name = "Civil" + m_CivilID.ToString();
            m_CivilID++;
            if (hiddenFanChance <= GameParameters.Instance.m_CivilFanProbability)
            {
                CustomLogger.debug(this, "hiddenFanChance = " + hiddenFanChance, CustomLogger.civilLog);
                civilInstance.GetComponent <Civil> ().SetHiddenFan(true);
            }
        }
    }
Пример #26
0
    public IEnumerator Walk()
    {
        CustomLogger.debug(this, "Walk", CustomLogger.vipLog);
        Vector3 goal = ComputeInterestPoint(10);

        m_NavAgent.ResetPath();
        m_NavAgent.SetDestination(goal);
        m_NavAgent.Resume();
        while (Vector3.Distance(this.transform.position, goal) > 1f)
        {
//			CustomLogger.debug (this, "m_NavAgent.velocity = "+m_NavAgent.velocity, CustomLogger.vipLog);
//			CustomLogger.debug (this, "goal distance = "+Vector3.Distance(this.transform.position,goal), CustomLogger.vipLog);
//			CustomLogger.debug (this, "transform.position = "+transform.position, CustomLogger.vipLog);
//			CustomLogger.debug (this, "goal.position = "+goal, CustomLogger.vipLog);
//			CustomLogger.debug (this, "nav mesh goal  = "+m_NavAgent.pathEndPosition, CustomLogger.vipLog);
            AlignBody(m_NavAgent.velocity);
            yield return(new WaitForFixedUpdate());
        }
        StopActions();
        m_Wait = StartCoroutine(Wait());
    }
Пример #27
0
 public void ApplyDamage(int damages)
 {
     CustomLogger.debug(this, "ApplyDamage", CustomLogger.fanLog);
     if (!m_Immune)
     {
         m_HeartPoint--;
         if (m_HeartPoint > 0)
         {
             m_TakingHit = StartCoroutine(TakingHit());
         }
         else
         {
             StopActions();
             StartCoroutine(Dying());
         }
     }
     else
     {
         CustomLogger.debug(this, "being hitting", CustomLogger.fanLog);
     }
 }
Пример #28
0
    private IEnumerator SendFanWaves()
    {
        CustomLogger.debug(this, "SendFanWaves", CustomLogger.gameLog);
        if (GameParameters.Instance.m_ActiveFanWaves == true)
        {
            yield return(new WaitForSeconds(GameParameters.Instance.m_StartWaveTimerSec));

            GameParameters.Instance.m_ActiveHiddenFan = true;
            float timeBetweenWave = 0;
            while (true)
            {
                timeBetweenWave -= Time.deltaTime;
                if (timeBetweenWave <= 0)
                {
                    CustomLogger.debug(this, "SpawnFanWave", CustomLogger.gameLog);
                    SpawnManager.Instance.SpawnFanWave();
                    timeBetweenWave = GameParameters.Instance.m_TimeBetweenWave;
                }
                yield return(new WaitForEndOfFrame());
            }
        }
    }
Пример #29
0
    // Marche vers une sortie du niveau
    public IEnumerator LeaveLevel()
    {
        CustomLogger.debug(this, "LeaveLevel", CustomLogger.civilLog);
        m_CurrentBehavior = "Leave";
        List <Transform> civilSpawners = SpawnManager.Instance.GetCivilSpawners();
        int rand = Random.Range(0, civilSpawners.Count);

        CustomLogger.debug(this, "Exit spawner = " + civilSpawners [rand].name, CustomLogger.civilLog);
        Vector3 goal = civilSpawners [rand].position;

        m_NavAgent.destination = goal;
        m_NavAgent.Resume();
        while (Vector3.Distance(this.transform.position, goal) > 1f)
        {
            AlignBody(m_NavAgent.velocity);
            yield return(new WaitForFixedUpdate());
        }
        StopActions();
        CustomLogger.debug(this, "Leaving", CustomLogger.civilLog);
        SpawnManager.Instance.RespawnCivils(1);
        Destroy(this.gameObject);
    }
Пример #30
0
 public void Dash()
 {
     CustomLogger.debug(this, "Dash", CustomLogger.guardLog);
     m_Dash = StartCoroutine(Dashing());
 }