Example #1
0
		public override void Start(object context)
		{
			base.Start(context);

			DisposeCoroutine();
			coroutine = coroutineProducer(context);
		}
Example #2
0
    public override void attack(WeaponController weaponController, float attackRate, bool isNewAttack, Vector2 aiInput)
    {
        if (!isAttacking && isReady) {
            Vector2 rockPos = new Vector2(weaponController.transform.position.x, weaponController.transform.position.y);
            if (aiInput.Equals(Vector2.zero))
            {
                return;
            }

            Vector2 lookAtDir = aiInput.normalized;

            GameObject rockWall = MonoBehaviour.Instantiate(weaponController.associatedPrefab,
                rockPos + (aiInput.normalized * wallDist),
                new Quaternion(0, 0, 0, 0)) as GameObject;
            rockWall.transform.Rotate(Vector3.forward, (180.0f / Mathf.PI) * Mathf.Atan2(lookAtDir.y, lookAtDir.x));

            MonoBehaviour.Destroy(rockWall, coolDownTime);

            // Start cooldown
            if (coolDownCorout != null)
            {
                weaponController.StopCoroutine(coolDownCorout);
            }
            coolDownCorout = weaponController.StartCoroutine(coolDown());
        }
    }
Example #3
0
 void Awake()
 {
     coroRecovery = null;
     _maxHP = 0;
     _currentHP = 0;
     recoverySpeed = 0;
 }
Example #4
0
    public void Pan(Vector3 direction, float panTime)
    {
        if (m_PanCR != null)
            StopCoroutine(m_PanCR);

        m_PanCR = StartCoroutine(pan_cr(direction, panTime));
    }
Example #5
0
    public void Zoom(float zoomScale, float zoomTime)
    {
        if(m_ZoomCR!=null)
            StopCoroutine(m_ZoomCR);

        m_ZoomCR = StartCoroutine(zoom_cr(zoomScale, zoomTime));
    }
 public override void Update()
 {
     if (flyRoutine == null)
     {
         flyRoutine = TaskFollower.StartCoroutine(FlyRoutine());
     }
 }
	public void OnEnable()
	{
		if (DrawAfterPostEffects)
		{
			m_DrawAtEndOfFrame = StartCoroutine("DrawAtEndOfFrame");
		}
	}
Example #8
0
    protected IEnumerator PanelTransition(bool isShowing)
    {
        //Init
        float timeLeft = 0f;
        JEngine.Instance.uiManager.nbPanelInTransition++;

        //Process
        yield return new WaitForEndOfFrame();
        if (isShowing)
        {
            while (canvasGroup.alpha < 1f)
            {
                timeLeft += Time.unscaledDeltaTime;
                canvasGroup.alpha = transitionCurve.Evaluate(timeLeft / transitionDuration);
				yield return new WaitForEndOfFrame();
            }
        }
        else
        {
            while (canvasGroup.alpha > 0f)
            {
                timeLeft += Time.unscaledDeltaTime;
                canvasGroup.alpha = transitionCurve.Evaluate(1f - (timeLeft / transitionDuration));
				yield return new WaitForEndOfFrame();
            }
            canvasGroup.blocksRaycasts = false;
        }

        transitionCoroutine = null;
        JEngine.Instance.uiManager.nbPanelInTransition--;
    }
//--------------------------------------------------------------------------------------------

    void Start ()
	{
		// get handle on player script
		playerScript = GetComponent<Player> ();
		if(playerScript.chassisQuick) 
		{
			rechargeRate *= playerScript.cooldownBoost;
		}

		//get handle on energy bar
		energyBar = GameObject.Find("EnergyBar").GetComponent<RectTransform>();
		origin = energyBar.localPosition;

		energySprites = Resources.LoadAll<Sprite>("GUI_Assets/EnergyIcons");
		energyImg = GameObject.Find("EnergyImg").GetComponent<Image>();
		blinkCoroutine = null;

        meshList =  playerScript.GetComponentsInChildren<MeshRenderer>();

        currEnergy = maxEnergy;

		isActive = false;
		isOnCooldown = false;
		isOnCooldownDelay = false;
		isOnInitialActivate = false;

		//get handle on audio source for secondary ready
		AudioSource[] sources = GetComponents<AudioSource>();
		readyAudio = sources[1];

		//audio source for phase on and off
		onSound = sources[2];
		offSound = sources[3];
	}
//--------------------------------------------------------------------------------------------

	void Start()
	{
		//get handle on energy bar
		energyBar = GameObject.Find("EnergyBar").GetComponent<RectTransform>();
		origin = energyBar.localPosition;

		energySprites = Resources.LoadAll<Sprite>("GUI_Assets/EnergyIcons");
		energyImg = GameObject.Find("EnergyImg").GetComponent<Image>();
		blinkCoroutine = null;

		//init prefabs
		teslaPrefabPhase_1 = Resources.Load<GameObject>("PlayerBullets/TeslaPhase_1");
		teslaPrefabPhase_2 = Resources.Load<GameObject>("PlayerBullets/TeslaPhase_2");

		forwardPos = transform.Find ("GunF");

		currEnergy = maxEnergy;
		storedDamage = 0f;

		isCharging = false;
		isOnInitialActivate = false;
		isOnCooldownDelay = false;
		isOnCooldown = false;

		//get handle on audio source for secondary ready
		readyAudio = GetComponents<AudioSource>()[1];
	}
Example #11
0
	// Use this for initialization
	void Start () {
		spriteRenderer = GetComponent<SpriteRenderer> ();
		if (start) 
		{
			currentCoroutine = StartCoroutine (ChangeSprite ());
		}
	}
    private void OnFailure()
    {
        if (m_DisplayFailureCoroutine != null)
            StopCoroutine(m_DisplayFailureCoroutine);

        m_DisplayFailureCoroutine = StartCoroutine(DisplayFailure());
    }
Example #13
0
    public void JumpTo(WorldMapArea area)
    {
        Debug.Assert(jumpRoutine == null, "jump routine must not already be in progress");

        jumpTarget = area;
        jumpRoutine = StartCoroutine(JumpRoutine());
    }
 private void longPressHandle(object sender, System.EventArgs e)
 {
     if (MenuMaster.musicVolume > 0 && MenuMaster.musicVolume < 100)
     {
         fastChanger = StartCoroutine(fastChange());
     }
 }
Example #15
0
 public void Activate()
 {
     textMesh.text = changeText;
     if( coRoutine != null )
         StopCoroutine( "resetText" );
     coRoutine = StartCoroutine( "resetText" );
 }
//--------------------------------------------------------------------------------------------

	void Start ()
	{
		// get handle on player script
		playerScript = GetComponent<Player> ();
		if(playerScript.chassisQuick) 
		{
			rechargeRate *= playerScript.cooldownBoost;
		}

		energyBar = GameObject.Find("EnergyBar").GetComponent<RectTransform>();
		origin = energyBar.localPosition;

		energySprites = Resources.LoadAll<Sprite>("GUI_Assets/EnergyIcons");
		energyImg = GameObject.Find("EnergyImg").GetComponent<Image>();
		blinkCoroutine = null;

		//init emp area prefab
		empAreaPrefab = Resources.Load<GameObject>("PlayerBullets/EMPArea");

		currEnergy = maxEnergy;
		isOnCooldown = false;

		//get handle on audio source for secondary ready
		readyAudio = GetComponents<AudioSource>()[1];
	}
Example #17
0
	public void MakeAnnouncement(string text,Color color, float lingerDuration = 1f){
		if(alertRoutine != null) StopCoroutine(alertRoutine);
		
		alert.text = text;
		alert.color = color;
		alertRoutine = StartCoroutine(PunchIn(alert.transform, lingerDuration));
	}
Example #18
0
	// Update is called once per frame
	void Update ()
	{
		if (target == null)
		{
			return;
		}

		var dist = Vector3.Distance(target.transform.position, transform.position);
        if (dist < followDistance)
		{
			hasLockedOn = true;
		}

		if (hasLockedOn == false)
		{
			return;
		}

		if (dist < shootDistance && shootRoutine == null)
		{
			shootRoutine = StartCoroutine(Shoot());
		}

		childTransform.rotation = Quaternion.Slerp(childTransform.rotation, Quaternion.LookRotation(target.position - childTransform.position), turnSpeed * Time.deltaTime);
        transform.position = Vector3.MoveTowards(transform.position, (transform.position - target.position).normalized * stopDistance + target.position, Time.deltaTime * moveSpeed);

		if (rigidBody.position.y > 2)
		{
			rigidBody.position = new Vector3(rigidBody.position.x, 2, rigidBody.position.z);
		}

		rigidBody.velocity = Vector3.zero;
		rigidBody.angularVelocity = Vector3.zero;
	}
 IEnumerator flyToTarget(int newTarget)
 {
     flying = true;
     int oldTarget = newTarget;
     currentTarget = newTarget;
     float startTime = Time.time;
     Vector3 t1 = targets[oldTarget].transform.position;
     Vector3 t2 = targets[newTarget].transform.position;
     float distance = Vector3.Distance(t1, t2);
     float trimmedDistance = distance;
     float minDistance = 10;
     float maxDistance = 100;
     if(trimmedDistance > maxDistance) trimmedDistance = maxDistance;
     else if(trimmedDistance < minDistance) trimmedDistance = minDistance;
     float additionalTime = map(trimmedDistance, minDistance, maxDistance, 1f, 3f);
     float endTime = startTime + additionalTime;
     Vector3 startPosition = transform.position;
     Vector3 endPosition = targets[newTarget].transform.position + offset;
     while(Time.time < endTime)
     {
         float p = (Time.time - startTime) / (endTime - startTime);
         p = p*p * (3f - 2f*p);
         p = p*p * (3f - 2f*p);
         p = p*p * (3f - 2f*p);
         transform.position = Vector3.Lerp(startPosition, endPosition, p);
         yield return 0;
     }
     flying = false;
     flyingCoroutine = null;
 }
Example #20
0
    public void Restart()
    {
		if(Hazards.Count > 0)
		{
			spawn_coroutine = StartCoroutine(SpawnRandomHazard());
		}
    }
    public void TimeoutStartButton()
    {
        if (this.TimeoutRoutine != null)
            { StopCoroutine(this.TimeoutRoutine); }

        this.TimeoutRoutine = StartCoroutine(DoStartButtonTimeout());
    }
Example #22
0
    public void animateBlock(int currentBlockCount,int maxCount)
    {
        if (co != null)
            StopCoroutine(co);

        if(currentBlockCount > maxCount / 2)//more then half
        {
            mySR.color = new Color(1,1,1,1);//white
        }
        else if (currentBlockCount == 1)
        {
            mySR.color = new Color(1, 0, 0, 1);//red
        }
        //else if (currentBlockCount == 0)//block count is 0
        //{
        //    mySR.color = new Color(mySR.color.r, mySR.color.g, mySR.color.b, 0);
        //}
        else
        {
            mySR.color = new Color(1, 1, 0, 1);//yellow
        }

        //mySR.color = new Color(mySR.color.r, mySR.color.g, mySR.color.b, 1);
        alpha = mySR.color.a;
        myanimator.enabled = true;
        co = StartCoroutine(fadeOut());
    }
Example #23
0
	// Update is called once per frame
	void Update () {
        if (player.greenPower && !routinerunning)
        {
            greenCoroutine = StartCoroutine(greenPowerTimerMethod());
        }
        transform.Rotate(Vector3.forward * speed * Time.deltaTime);
    }
Example #24
0
    // Update is called once per frame
    void Update()
    {
        if(Input.GetKeyUp (KeyCode.Space)){

            switchAlly = !switchAlly;
        }
        //Raycasting
        if (Input.GetMouseButtonUp (0)) {

            Ray r = Camera.main.ScreenPointToRay (Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast (r, out hit, float.MaxValue)) {
                //Debug.Log ("hit: " + hit.collider.name );

                if(hit.collider.name == "Ground" ){

                    if(switchAlly == true && quantity_player_a < 3){

                        clone = Instantiate (ally_a, hit.point, allyTransform_a.rotation) as GameObject;
                        quantity_player_a++;
                        c = StartCoroutine (DeleteAlly(clone));

                    }else if(switchAlly == false && quantity_player_b < 3){

                        clone = Instantiate (ally_b, hit.point, allyTransform_b.rotation) as GameObject;
                        quantity_player_b++;
                        c = StartCoroutine (DeleteAlly(clone));
                    }

                }

                }
            }
    }
Example #25
0
	void Move(Vector3 newPos, float duration, float delay)
	{
		if (_moveCoroutine != null)
			StopCoroutine(_moveCoroutine);
		
		_moveCoroutine = StartCoroutine(MoveRoutine(newPos, duration, delay));
	}
Example #26
0
	// Update is called once per frame
	void Update () {
		if(dialogManager.getID() >= startAtDialogNumber && dialogManager.getID() < endAtDialogNumber && !audioSource.isPlaying && !activate)
		{
			coroutineSound = StartCoroutine(WaitAndPlay(secondsToStart));
			activate = true;
		}

		if(dialogManager.getID() >= endAtDialogNumber && activate)
		{
			StopCoroutine(coroutineSound);
		}

		if(dialogManager.getID() >= endAtDialogNumber && audioSource.isPlaying && !activateEnd)
		{
			audioSource.loop = false;
			activateEnd = true;

			if(trailSource != null)
			{
            	trailSource.PlayScheduled( AudioSettings.dspTime + audioSource.clip.length - audioSource.time);
			}
		}

		//if(dialogManager.getID() >= endAtDialogNumber && !audioSource.isPlaying && activateEnd && !activateTrail)
		//{
		//	trailSource.Play();
		//	activateTrail = true;
		//}
	}
    public void Close(float time, Action onFinish)
    {
        if (m_Coroutine != null)
            StopCoroutine(m_Coroutine);

        m_Coroutine = StartCoroutine(MoveEyelidsCoroutine(0.0f, 0.0f, time, onFinish));
    }
Example #28
0
	public override void Activate()
	{
		if (movement != null)
			StopCoroutine (movement);
		movement = StartCoroutine (Movement(transform.TransformPoint (openedPosition)));
        SoundManager.Instance.SendMessage("PlaySFXOpenGate");
	}
Example #29
0
 public WaitForSeconds(Coroutine coroutine, double seconds)
 {
     this.coroutine = coroutine;
     TimeoutEvent e = new TimeoutEvent { Key = this };
     token = Flow.Bind(e, OnTimeout);
     TimeFlow.Default.Reserve(e, seconds);
 }
    public void Open(float time, Action onFinish)
    {
        if (m_Coroutine != null)
            StopCoroutine(m_Coroutine);

        m_Coroutine = StartCoroutine(MoveEyelidsCoroutine(m_OpenedUpperEyelidY, m_OpenedLowerEyelidY, time, onFinish));
    }
Example #31
0
        public async Task<bool> Cast(GameObject target = null, bool checkGCDType = true)
        {
            #region Target

            if (target == null)
                switch (CastType)
                {
                    case CastType.Target:
                    case CastType.TargetLocation:
                        if (!Core.Player.HasTarget) return false;
                        target = Core.Player.CurrentTarget;
                        break;
                    default:
                        target = Core.Player;
                        break;
                }

            #endregion

            #region RecentSpell

            RecentSpell.RemoveAll(t => DateTime.UtcNow > t);
            if (RecentSpell.ContainsKey(target.ObjectId.ToString("X") + "-" + Name)) return false;

            #endregion

            #region CapabilityManager

            if (RoutineManager.IsAnyDisallowed(CapabilityFlags.Movement | CapabilityFlags.Facing)) return false;

            #endregion

            #region Cooldown

            if (ShinraEx.Settings.CooldownMode == CooldownModes.Disabled)
                if ((SpellType == SpellType.Buff || SpellType == SpellType.Cooldown) && Cooldown(true) > 2500)
                    return false;

            #endregion

            #region AoE

            if (SpellType == SpellType.AoE && ShinraEx.Settings.RotationMode != Modes.Multi)
            {
                if (RoutineManager.IsAnyDisallowed(CapabilityFlags.Aoe)) return false;

                var enemyCount =
                    Helpers.Enemies.Count(eu => eu.Distance2D(target) - eu.CombatReach - target.CombatReach <=
                                                DataManager.GetSpellData(ID).Radius);

                if (ShinraEx.Settings.CustomAoE)
                {
                    if (enemyCount < ShinraEx.Settings.CustomAoECount) return false;
                }
                else
                {
                    switch (Core.Player.CurrentJob)
                    {
                        case ClassJobType.Arcanist:
                        case ClassJobType.Summoner:
                            if (enemyCount < 2) return false;
                            break;
                        default:
                            if (enemyCount < 3) return false;
                            break;
                    }
                }
            }

            #endregion

            #region Directional

            switch (ID)
            {
                // Cone
                case 41:
                case 70:
                case 106:
                case 7483:
                case 7488:
                {
                    if (!Helpers.InView(Core.Player.Location, Core.Player.Heading, target.Location))
                        return false;
                    break;
                }

                // Line
                case 86:
                case 7496:
                {
                    if (!Core.Player.IsFacing(target))
                        return false;
                    break;
                }
            }

            #endregion

            #region Pet

            switch (SpellType)
            {
                case SpellType.Pet when Core.Player.Pet == null:
                case SpellType.Pet when PetManager.PetMode != PetMode.Obey:
                case SpellType.Pet when Core.Player.IsMounted:
                case SpellType.Pet when !PetManager.CanCast(Name, target):
                case SpellType.Pet when !await Coroutine.Wait(5000, () => PetManager.DoAction(Name, target)):
                    return false;
                case SpellType.Pet:
                {
                    ShinraEx.LastSpell = this;

                    #region AddRecent

                    var key = target.ObjectId.ToString("X") + "-" + Name;
                    var val = DateTime.UtcNow + TimeSpan.FromSeconds(3);
                    RecentSpell.Add(key, val);

                    #endregion

                    Logging.Write(Colors.GreenYellow, $@"[ShinraEx] Casting >>> {Name}");
                    return true;
                }

                case SpellType.Card when Core.Player.IsMounted:
                case SpellType.Card when !ActionManager.CanCast(ID, target) || RecentSpell.ContainsKey("Card"):
                case SpellType.Card when !await Coroutine.Wait(1000, () => ActionManager.DoAction(ID, target)):
                    return false;
                case SpellType.Card:
                {
                    ShinraEx.LastSpell = this;

                    #region AddRecent

                    var val = DateTime.UtcNow + TimeSpan.FromSeconds(.5);

                    if (ID == 3593) val += TimeSpan.FromSeconds(2);
                    RecentSpell.Add("Card", val);

                    #endregion

                    Logging.Write(Colors.GreenYellow, $@"[ShinraEx] Casting >>> {Name}");
                    return true;
                }
            }

            #endregion

            #region Card

            if (ShinraEx.Settings.AstrologianCardOnly && Core.Player.CurrentJob == ClassJobType.Astrologian)
                return false;

            #endregion

            #region Ninjutsu

            if (SpellType == SpellType.Ninjutsu || SpellType == SpellType.Mudra)
            {
                #region Movement

                if (BotManager.Current.IsAutonomous)
                    switch (ActionManager.InSpellInRangeLOS(2247, target))
                    {
                        case SpellRangeCheck.ErrorNotInLineOfSight:
                            await CommonTasks.MoveAndStop(new MoveToParameters(target.Location), 0f);
                            return false;
                        case SpellRangeCheck.ErrorNotInRange:
                            await CommonTasks.MoveAndStop(new MoveToParameters(target.Location), 0f);
                            return false;
                        case SpellRangeCheck.ErrorNotInFront:
                            if (!target.InLineOfSight())
                            {
                                await CommonTasks.MoveAndStop(new MoveToParameters(target.Location), 0f);
                                return false;
                            }

                            target.Face();
                            return false;
                        case SpellRangeCheck.Success:
                            if (MovementManager.IsMoving) Navigator.PlayerMover.MoveStop();
                            break;
                    }

                #endregion

                #region IsMounted

                if (Core.Player.IsMounted) return false;

                #endregion

                #region CanCast

                if (ShinraEx.Settings.QueueSpells &&
                    !ActionManager.CanCastOrQueue(DataManager.GetSpellData(ID), target) ||
                    !ActionManager.CanCast(ID, target))
                    return false;

                #endregion

                #region DoAction

                if (!await Coroutine.Wait(1000, () => ActionManager.DoAction(ID, target))) return false;

                #endregion

                #region Wait

                await Coroutine.Wait(2000, () => !ActionManager.CanCast(ID, target));

                #endregion

                ShinraEx.LastSpell = this;

                #region AddRecent

                if (SpellType == SpellType.Mudra)
                {
                    var key = target.ObjectId.ToString("X") + "-" + Name;
                    var val = DateTime.UtcNow + TimeSpan.FromSeconds(1);
                    RecentSpell.Add(key, val);
                }

                #endregion

                Logging.Write(Colors.GreenYellow, $@"[ShinraEx] Casting >>> {Name}");
                return true;
            }

            #endregion

            #region CanAttack

            var bc = target as BattleCharacter;

            if (!target.CanAttack && CastType != CastType.Self && CastType != CastType.SelfLocation &&
                (bc == null || !bc.IsFate))
                switch (SpellType)
                {
                    case SpellType.Damage:
                    case SpellType.DoT:
                    case SpellType.Cooldown:
                        return false;
                }

            #endregion

            #region HasSpell

            if (!ActionManager.HasSpell(ID)) return false;

            #endregion

            #region Movement

            if (BotManager.Current.IsAutonomous)
            {
                switch (ActionManager.InSpellInRangeLOS(ID, target))
                {
                    case SpellRangeCheck.ErrorNotInLineOfSight:
                        await CommonTasks.MoveAndStop(new MoveToParameters(target.Location), 0f);
                        Helpers.Debug($"LineOfSight >>> {Name}");
                        return false;
                    case SpellRangeCheck.ErrorNotInRange:
                        await CommonTasks.MoveAndStop(new MoveToParameters(target.Location), 0f);
                        Helpers.Debug($"Range >>> {Name}");
                        return false;
                    case SpellRangeCheck.ErrorNotInFront:
                        if (!target.InLineOfSight())
                        {
                            await CommonTasks.MoveAndStop(new MoveToParameters(target.Location), 0f);
                            Helpers.Debug($"Facing >>> {Name}");
                            return false;
                        }

                        target.Face();
                        return false;
                    case SpellRangeCheck.Success:
                        if (CastType == CastType.TargetLocation && Core.Player.Distance2D(target) +
                            Core.Player.CombatReach +
                            target.CombatReach > 25)
                        {
                            await CommonTasks.MoveAndStop(new MoveToParameters(target.Location), 0f);
                            await Coroutine.Wait(1000,
                                () => Core.Player.Distance2D(target) + Core.Player.CombatReach + target.CombatReach <=
                                      25);
                            return false;
                        }

                        Navigator.PlayerMover.MoveStop();
                        break;
                }

                if (Core.Player.HasTarget && !MovementManager.IsMoving && Core.Player.IsMounted)
                {
                    Logging.Write(Colors.Yellow, @"[ShinraEx] Dismounting...");
                    ActionManager.Dismount();
                    await Coroutine.Sleep(1000);
                }
            }

            #endregion

            #region IsMounted

            if (Core.Player.IsMounted) return false;

            #endregion

            #region StopCasting

            if (SpellType == SpellType.Heal)
                if (Core.Player.IsCasting && !Helpers.HealingSpells.Contains(Core.Player.SpellCastInfo.Name))
                {
                    var stopCasting = false;
                    switch (Core.Player.CurrentJob)
                    {
                        case ClassJobType.Astrologian:
                            stopCasting = ShinraEx.Settings.AstrologianInterruptDamage;
                            break;
                        case ClassJobType.Scholar:
                            stopCasting = ShinraEx.Settings.ScholarInterruptDamage;
                            break;
                        case ClassJobType.WhiteMage:
                            stopCasting = ShinraEx.Settings.WhiteMageInterruptDamage;
                            break;
                    }

                    if (stopCasting)
                    {
                        Helpers.Debug($@"Trying to cast {Name}");
                        Logging.Write(Colors.Yellow, $@"[ShinraEx] Interrupting >>> {Core.Player.SpellCastInfo.Name}");
                        ActionManager.StopCasting();
                        await Coroutine.Wait(500, () => !Core.Player.IsCasting);
                    }
                }

            #endregion

            #region CanCast

            switch (CastType)
            {
                case CastType.TargetLocation:
                case CastType.SelfLocation:
                    if (!ActionManager.CanCastLocation(ID, target.Location) || Core.Player.IsCasting) return false;
                    break;
                default:
                    if (ShinraEx.Settings.QueueSpells && GCDType == GCDType.On)
                    {
                        if (!ActionManager.CanCastOrQueue(DataManager.GetSpellData(ID), target)) return false;
                    }
                    else
                    {
                        if (!ActionManager.CanCast(ID, target)) return false;
                    }

                    break;
            }

            if (MovementManager.IsMoving && DataManager.GetSpellData(ID).AdjustedCastTime.TotalMilliseconds > 0)
            {
                if (!BotManager.Current.IsAutonomous) return false;
                Navigator.PlayerMover.MoveStop();
            }

            #endregion

            #region InView

            if (GameSettingsManager.FaceTargetOnAction == false && CastType == CastType.Target &&
                SpellType != SpellType.Heal &&
                SpellType != SpellType.Buff &&
                !Helpers.InView(Core.Player.Location, Core.Player.Heading, target.Location))
                return false;

            #endregion

            #region GCD

            if (GCDType == GCDType.Off && checkGCDType)
                switch (Core.Player.CurrentJob)
                {
                    case ClassJobType.Arcanist:
                    case ClassJobType.Scholar:
                    case ClassJobType.Summoner:
                        if (DataManager.GetSpellData(163).Cooldown.TotalMilliseconds < 1000) return false;
                        break;
                    case ClassJobType.Archer:
                    case ClassJobType.Bard:
                        if (DataManager.GetSpellData(97).Cooldown.TotalMilliseconds < 1000) return false;
                        break;
                    case ClassJobType.Astrologian:
                        if (DataManager.GetSpellData(3594).Cooldown.TotalMilliseconds < 1000) return false;
                        break;
                    case ClassJobType.Conjurer:
                    case ClassJobType.WhiteMage:
                        if (DataManager.GetSpellData(119).Cooldown.TotalMilliseconds < 1000) return false;
                        break;
                    case ClassJobType.DarkKnight:
                       // if (DataManager.GetSpellData(3617).Cooldown.TotalMilliseconds < 1000) return false;
                       // break;
                    case ClassJobType.Gladiator:
                    case ClassJobType.Paladin:
                        if (DataManager.GetSpellData(9).Cooldown.TotalMilliseconds < 1000) return false;
                        break;
                    case ClassJobType.Lancer:
                    case ClassJobType.Dragoon:
                        if (ID == 8801 || ID == 8802)
                            if (DataManager.GetSpellData(75).Cooldown.TotalMilliseconds < 1500) return false;
                        else if (DataManager.GetSpellData(75).Cooldown.TotalMilliseconds < 1000)
                            return false;

                        break;
                    case ClassJobType.Machinist:
                        if (DataManager.GetSpellData(2866).Cooldown.TotalMilliseconds < 1000) return false;
                        break;
                    case ClassJobType.Marauder:
                    case ClassJobType.Warrior:
                        if (DataManager.GetSpellData(31).Cooldown.TotalMilliseconds < 1000) return false;
                        break;
                    case ClassJobType.Pugilist:
                    case ClassJobType.Monk:
                        if (DataManager.GetSpellData(53).Cooldown.TotalMilliseconds < 1000) return false;
                        break;
                    case ClassJobType.RedMage:
                        if (DataManager.GetSpellData(7504).Cooldown.TotalMilliseconds < 1000) return false;
                        break;
                    case ClassJobType.Rogue:
                    case ClassJobType.Ninja:
                        if (DataManager.GetSpellData(2240).Cooldown.TotalMilliseconds < 1000) return false;
                        break;
                    case ClassJobType.Samurai:
                        if (DataManager.GetSpellData(7477).Cooldown.TotalMilliseconds < 1000) return false;
                        break;
                    case ClassJobType.Thaumaturge:
                    case ClassJobType.BlackMage:
                        if (DataManager.GetSpellData(142).Cooldown.TotalMilliseconds < 1000) return false;
                        break;
                }

            #endregion

            #region DoAction

            switch (CastType)
            {
                case CastType.TargetLocation:
                    if (ShinraEx.Settings.RandomCastLocations)
                    {
                        var randX = target.CombatReach * _rand.NextDouble() * GetMultiplier();
                        var randZ = target.CombatReach * _rand.NextDouble() * GetMultiplier();
                        var randXYZ = new Vector3((float) randX, 0f, (float) randZ);
                        var newLocation = target.Location + randXYZ;

                        if (!await Coroutine.Wait(1000, () => ActionManager.DoActionLocation(ID, newLocation)))
                            return false;
                    }
                    else
                    {
                        if (!await Coroutine.Wait(1000, () => ActionManager.DoActionLocation(ID, target.Location)))
                            return false;
                    }

                    break;
                case CastType.SelfLocation:
                    if (ShinraEx.Settings.RandomCastLocations)
                    {
                        var randX = (1f * _rand.NextDouble() + 1f) * GetMultiplier();
                        var randZ = (1f * _rand.NextDouble() + 1f) * GetMultiplier();
                        var randXYZ = new Vector3((float) randX, 0f, (float) randZ);
                        var newLocation = target.Location + randXYZ;

                        if (!await Coroutine.Wait(1000, () => ActionManager.DoActionLocation(ID, newLocation)))
                            return false;
                    }
                    else
                    {
                        if (!await Coroutine.Wait(1000, () => ActionManager.DoActionLocation(ID, target.Location)))
                            return false;
                    }

                    break;
                default:
                    if (SpellType == SpellType.PVP)
                    {
                        if (!await Coroutine.Wait(1000, () => ActionManager.DoPvPCombo(Combo, target))) return false;
                        Logging.Write(Colors.Orange, $@"DoAction Combo {Combo} 0x{target.ObjectId:X}");
                    }
                    else
                    {
                        if (!await Coroutine.Wait(1000, () => ActionManager.DoAction(ID, target))) return false;
                    }

                    break;
            }

            #endregion

            #region Wait

            switch (CastType)
            {
                case CastType.SelfLocation:
                case CastType.TargetLocation:
                    await Coroutine.Wait(3000, () => !ActionManager.CanCastLocation(ID, target.Location));
                    break;
                default:
                    await Coroutine.Wait(3000, () => !ActionManager.CanCast(ID, target));
                    break;
            }

            #endregion

            ShinraEx.LastSpell = this;
            Logging.Write(Colors.GreenYellow,
                $@"[ShinraEx] Casting >>> {Name}{(SpellType == SpellType.PVP ? " Combo" : "")}");

            #region AddRecent

            if (SpellType != SpellType.Damage && SpellType != SpellType.AoE && SpellType != SpellType.Heal &&
                SpellType != SpellType.PVP &&
                await CastComplete(this))
            {
                var key = target.ObjectId.ToString("X") + "-" + Name;
                var val = DateTime.UtcNow + DataManager.GetSpellData(ID).AdjustedCastTime + TimeSpan.FromSeconds(3);
                RecentSpell.Add(key, val);
            }

            if (SpellType == SpellType.Damage || SpellType == SpellType.DoT)
                if (!Helpers.OpenerFinished && !RecentSpell.ContainsKey("Opener") && await CastComplete(this, true))
                {
                    var val = DateTime.UtcNow + DataManager.GetSpellData(ID).AdjustedCastTime + TimeSpan.FromSeconds(3);
                    RecentSpell.Add("Opener", val);
                }

            #endregion

            return true;
        }
Example #32
0
 public void ShowThought(string thought, float duration)
 {
     Clear();
     currentCoroutine = StartCoroutine(ThoughtProcess(thought, duration));
 }
Example #33
0
    private IEnumerator OnTransitionCoroutine<T>(string resourceName, float fadeInDuration, float fadeOutDuration, System.Action<eSceneTransitionErrorCode> completed) where T : SceneBase
    {
        string currentPageType = m_currentScene ? m_currentScene.GetType().ToString() : string.Empty;
        string nextPageType = typeof(T).ToString();

        Global.WidgetMgr.ShowLoadingWidget(fadeInDuration, currentPageType, nextPageType);

        yield return new WaitForEndOfFrame();

        if (m_currentScene != null)
        {
            m_priviousPageTypeName = currentPageType;

            m_currentScene.OnFinalize();
            m_currentScene.OnExit();
        }

        yield return new WaitForEndOfFrame();

        float currentProgress = 0.0f;
        const float sceneLoadingProgressRate = 0.4f;

        if (string.IsNullOrEmpty(resourceName) == false)
        {
            UnityEngine.SceneManagement.Scene activeScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
            if (activeScene != null)
            {
                m_priviousResourceName = activeScene.name;
            }

            yield return Global.ResourceMgr.LoadSceneAsync(resourceName,
                (progress) =>
                {
                    // scene loading..
                    currentProgress = progress * sceneLoadingProgressRate;
                    Global.WidgetMgr.SetLoadingProgressInfo(currentProgress);

                    LogWarning(StringUtil.Format("OnTransitionCoroutine -> LoadScene {0} %", (int)(currentProgress * 100)));
                },
                () =>
                {
                    // completed scene load
                    currentProgress = sceneLoadingProgressRate;
                    Global.WidgetMgr.SetLoadingProgressInfo(currentProgress);

                    LogWarning("OnTransitionCoroutine -> Completed LoadScene.");
                });
        }
        else
        {
            currentProgress = sceneLoadingProgressRate;
        }

        m_currentScene = FindPage(typeof(T).ToString());

        if (m_currentScene == null)
        {
            m_currentScene = ComponentFactory.GetChildComponent<T>(RootObject != null ? RootObject : Setting.gameObject, IfNotExist.AddNew);
            AddPage(m_currentScene);
        }

        if (m_currentScene != null)
        {
            yield return m_currentScene.OnEnter(currentProgress);
            m_currentScene.OnInitialize();
        }

        yield return new WaitForEndOfFrame();

        if (completed != null)
        {
            Global.WidgetMgr.HideLoadingWidget(fadeOutDuration);
            completed(eSceneTransitionErrorCode.Success);
        }

        m_transitionCoroutine = null;
    }
Example #34
0
 public void BeginVisuals()
 {
     StopCoroutine(ref m_RotationVisualsCoroutine);
     m_RotationVisualsCoroutine = StartCoroutine(AnimateVisuals(true));
 }
Example #35
0
 private void SwitchBossState()
 {
     stateChangeCounter = 1;
     StopCoroutine(coroutine);
     coroutine = StartCoroutine(ThrowObject());
 }
Example #36
0
        public static async Task <bool> Ascend()
        {
            if (!AstrologianSettings.Instance.Ascend)
            {
                return(false);
            }

            if (!Globals.InParty)
            {
                return(false);
            }

            if (Core.Me.CurrentMana < Spells.Ascend.Cost)
            {
                return(false);
            }

            /*
             * if (Group.DeadAllies.Any())
             * {
             *  Logger.WriteInfo(
             *      @"========================================Dead Guy Logger========================================");
             *  var deadguycount = 0;
             *  foreach (var deadguy in Group.DeadAllies)
             *  {
             *      deadguycount++;
             *      Logger.WriteInfo($@"{deadguycount}" + "\t" + $@"{deadguy.Name}" + "\t" +
             *                       $@"DoesntHaveRaiseAura: {!deadguy.HasAura(Auras.Raise)}" + "\t" +
             *                       $@"Distance: {deadguy.Distance(Core.Me)}");
             *      Logger.WriteInfo("\t" + $@"InLineOfSight: {deadguy.InLineOfSight()}" + "\t" +
             *                       $@"IsTargetable: {deadguy.IsTargetable}" + "\t" +
             *                       $@"IsVisible: {deadguy.IsVisible}");
             *  }
             *  Logger.WriteInfo(
             *      @"========================================Dead Guy Logger========================================");
             * }
             */
            var deadList = Group.DeadAllies.Where(u => !u.HasAura(Auras.Raise) &&
                                                  u.Distance(Core.Me) <= 30 &&
                                                  u.InLineOfSight() &&
                                                  u.IsTargetable &&
                                                  u.IsVisible)
                           .OrderByDescending(r => r.GetResurrectionWeight());

            var deadTarget = deadList.FirstOrDefault();

            if (deadTarget == null)
            {
                return(false);
            }

            if (!deadTarget.IsTargetable)
            {
                return(false);
            }

            if (Core.Me.InCombat || Core.Me.OnPvpMap())
            {
                if (!ActionManager.HasSpell(Spells.Ascend.Id))
                {
                    return(false);
                }

                if (!AstrologianSettings.Instance.AscendSwiftcast)
                {
                    return(false);
                }

                if (!ActionManager.HasSpell(Spells.Swiftcast.Id))
                {
                    return(false);
                }

                if (Spells.Swiftcast.Cooldown != TimeSpan.Zero)
                {
                    return(false);
                }

                if (await Buff.Swiftcast())
                {
                    while (Core.Me.HasAura(Auras.Swiftcast))
                    {
                        if (await Spells.Ascend.Cast(deadTarget))
                        {
                            return(true);
                        }
                        await Coroutine.Yield();
                    }
                }
            }

            if (Core.Me.InCombat)
            {
                return(false);
            }

            return(await Spells.Raise.CastAura(deadTarget, Auras.Raise));
        }
Example #37
0
        public async Task RetainerRun()
        {
            var bell = await GoToSummoningBell();

            if (bell == false)
            {
                LogCritical("No summoning bell near by");
                TreeRoot.Stop("Done playing with retainers");
                return;
            }

            await RetainerRoutine.ReadRetainers(RetainerCheck);

            await Coroutine.Sleep(1000);

            if (!RetainerSettings.Instance.Loop || !RetainerSettings.Instance.ReassignVentures)
            {
                LogCritical($"Loop Setting {RetainerSettings.Instance.Loop} ReassignVentures {RetainerSettings.Instance.ReassignVentures}");
                TreeRoot.Stop("Done playing with retainers");
            }

            if (RetainerSettings.Instance.Loop && InventoryManager.FreeSlots < 2)
            {
                LogCritical($"I am overburdened....free up some space you hoarder");
                TreeRoot.Stop("Done playing with retainers");
            }

            var count = await GetNumberOfRetainers();

            var rets = Core.Memory.ReadArray <RetainerInfo>(Offsets.RetainerData, count);

            if (!rets.Any(i => i.VentureTask != 0 && i.Active))
            {
                LogCritical($"No ventures assigned or completed");
                TreeRoot.Stop("Done playing with retainers");
            }

            var nextVenture = rets.Where(i => i.VentureTask != 0 && i.Active).OrderBy(i => i.VentureEndTimestamp).First();

            if (nextVenture.VentureEndTimestamp == 0)
            {
                LogCritical($"No ventures running");
                TreeRoot.Stop("Done playing with retainers");
            }

            if (SpecialCurrencyManager.GetCurrencyCount(SpecialCurrency.Venture) <= 2)
            {
                LogCritical($"Get more venture tokens...bum");
                TreeRoot.Stop("Done playing with retainers");
            }

            var now      = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
            var timeLeft = nextVenture.VentureEndTimestamp - now;

            Log($"Waiting till {RetainerInfo.UnixTimeStampToDateTime(nextVenture.VentureEndTimestamp)}");
            await Coroutine.Sleep(timeLeft * 1000);

            await Coroutine.Sleep(30000);

            Log($"{nextVenture.Name} Venture should be done");
        }
Example #38
0
        public static async Task CheckForSuccessfulCast()
        {
            // If the timer isn't running it means it's already been stopped and the variables have already been set
            if (!CastingTime.IsRunning)
            {
                //CastingTankBuster = false;
                NeedAura       = false;
                UseRefreshTime = false;
                DoHealthChecks = false;
                CastingHeal    = false;
                //CastingTankBuster = false;
                CastingGambit = false;
                return;
            }

            #region Verify Successful Spell Cast

            //This is to ensure that the instant Action we just tried to use
            //was indeed used and not rejected from the server.
            //Logic behind this is, that every Action will trigger some kind of cooldown
            if (BaseSettings.Instance.UseAdvancedSpellHistory)
            {
                if (CastingSpell.AdjustedCastTime.TotalMilliseconds == 0 && CastingSpell.Cooldown.TotalMilliseconds == 0)
                {
                    return;
                }
            }

            // Compare Times
            Logger.WriteCast($@"Time Casting: {CastingTime.ElapsedMilliseconds} - Expected: {SpellCastTime.TotalMilliseconds}");
            var buffer = SpellCastTime.TotalMilliseconds - CastingTime.ElapsedMilliseconds;

            // Stop Timer
            CastingTime.Stop();

            // Did we successfully cast?
            if (buffer > 800)
            {
                NeedAura       = false;
                UseRefreshTime = false;
                DoHealthChecks = false;
                CastingHeal    = false;
                //CastingTankBuster = false;
                CastingGambit      = false;
                LastSpellSucceeded = false;
                return;
            }

            if (BaseSettings.Instance.DebugPlayerCasting)
            {
                Debug.Instance.CastingTime = CastingTime.ElapsedMilliseconds.ToString();
            }
            // Within 500 milliseconds we're gonna assume the spell went off
            LastSpell                = CastingSpell;
            LastSpellSucceeded       = true;
            Debug.Instance.LastSpell = LastSpell;
            LastSpellTimeFinishedUtc = DateTime.UtcNow;
            if (!LastSpellTimeFinishAge.IsRunning)
            {
                LastSpellTimeFinishAge.Start();
            }
            else
            {
                LastSpellTimeFinishAge.Restart();
            }
            LastSpellTarget = SpellTarget;
            Logger.WriteCast($@"Successfully Casted {LastSpell}");

            SpellCastHistory.Insert(0, new SpellCastHistoryItem
            {
                Spell          = LastSpell,
                SpellTarget    = SpellTarget,
                TimeCastUtc    = LastSpellTimeFinishedUtc,
                TimeStartedUtc = LastSpellTimeFinishedUtc.Subtract(TimeSpan.FromMilliseconds(CastingTime.ElapsedMilliseconds)),
                DelayMs        = CastingTime.ElapsedMilliseconds - SpellCastTime.TotalMilliseconds
            });

            if (BaseSettings.Instance.DebugSpellCastHistory)
            {
                Application.Current.Dispatcher.Invoke(delegate { Debug.Instance.SpellCastHistory = new List <SpellCastHistoryItem>(SpellCastHistory); });
            }

            #endregion

            #region Aura Checks

            if (NeedAura)
            {
                if (UseRefreshTime)
                {
                    await Coroutine.Wait(3000, () => SpellTarget.HasAura(Aura, true, RefreshTime) || MovementManager.IsMoving);
                }
                else
                {
                    await Coroutine.Wait(3000, () => SpellTarget.HasAura(Aura, true) || MovementManager.IsMoving);
                }

                if (CastingSpell.AdjustedCastTime == TimeSpan.Zero)
                {
                    await Coroutine.Wait(3000, () => SpellTarget.HasAura(Aura));
                }
            }

            #endregion

            #region Fill Variables

            /*if (CastingTankBuster)
             * {
             *  LastTankBusterTarget = SpellTarget;
             *  LastTankBusterSpell = CastingSpell;
             *  LastTankBusterTime = DateTime.Now;
             * }*/

            NeedAura       = false;
            UseRefreshTime = false;
            DoHealthChecks = false;
            CastingHeal    = false;
            //CastingTankBuster = false;
            CastingGambit = false;

            #endregion
        }
Example #39
0
    private void Update()
    {
        if (Time.timeScale == 0)
        {
            return;
        }

        Vector3 rawMousePos2 = Input.mousePosition;
        Vector3 mousePos2    = Camera.main.ScreenToWorldPoint(rawMousePos2);

        if (Input.GetKeyDown(KeyCode.Mouse0) && numOfAttack < 4 && this.gameObject.GetComponent <slingShot>().isClicked == false && anim.GetBool("isInAir") == false &&
            anim.GetBool("isGettingHit") == false && this.gameObject.GetComponent <PlayerCollision>().hitSide == false)
        {
            numOfAttack += 1;
            resetAtkTime = 0;
            Attack();
            if (mousePos2.x > this.transform.position.x + 0.3f)
            {
                this.gameObject.GetComponent <SpriteRenderer>().flipX = false;
            }
            else if (mousePos2.x < this.transform.position.x - 0.3f)
            {
                this.gameObject.GetComponent <SpriteRenderer>().flipX = true;
            }
            if (this.gameObject.GetComponent <PlayerCollision>().isAbleDash)
            {
                if (dashToMouse != null)
                {
                    StopCoroutine(dashToMouse);
                }
                dashToMouse = StartCoroutine(DashToMouse());
            }
        }

        //animator
        if (numOfAttack == 0)
        {
            anim.SetInteger("attackNum", 0);
        }
        else if (numOfAttack == 1)
        {
            anim.SetInteger("attackNum", 1);
            resetTimer();
        }
        else if (numOfAttack == 2)
        {
            anim.SetInteger("attackNum", 2);
            resetTimer();
        }
        else if (numOfAttack == 3)
        {
            anim.SetInteger("attackNum", 3);
            resetTimer();
        }
        else if (numOfAttack == 4)
        {
            anim.SetInteger("attackNum", 4);
            resetTimer();
        }
        if (numOfAttack == 0)
        {
            if (mousePos2.x > this.transform.position.x + 0.3f)
            {
                this.gameObject.GetComponent <SpriteRenderer>().flipX = false;
            }
            else if (mousePos2.x < this.transform.position.x - 0.3f)
            {
                this.gameObject.GetComponent <SpriteRenderer>().flipX = true;
            }
        }
    }
Example #40
0
    private void Start()
    {
        StoreInit();

        CreateQuest = StartCoroutine(QuestController.CreateQuestCoroutine());
    }
Example #41
0
 private void Start()
 {
     coroutine = StartCoroutine(ThrowObject());
 }
 private void Start()
 {
     _spinCoroutine = StartCoroutine(Spin());
 }
Example #43
0
 public void StartFlickering()
 {
     m_FlickerCoroutine = StartCoroutine(Flicker());
 }
Example #44
0
 void Start()
 {
     spawnEnemies = StartCoroutine(SpawnEnemies());
 }
Example #45
0
        public static async Task <bool> RetainerHandleVentures()
        {
            if (!SelectString.IsOpen)
            {
                return(false);
            }

            if (SelectString.Lines().Contains(Translator.VentureCompleteText))
            {
                //Log("Venture Done");
                SelectString.ClickLineEquals(Translator.VentureCompleteText);

                await Coroutine.Wait(5000, () => RetainerTaskResult.IsOpen);

                if (!RetainerTaskResult.IsOpen)
                {
                    Log("RetainerTaskResult didn't open");
                    return(false);
                }

                var taskId = AgentRetainerVenture.Instance.RetainerTask;

                var task = VentureData.Value.FirstOrDefault(i => i.Id == taskId);

                if (task != default(RetainerTaskData))
                {
                    Log($"Finished Venture {task.Name}");
                    Log($"Reassigning Venture {task.Name}");
                }
                else
                {
                    Log($"Finished Venture");
                    Log($"Reassigning Venture");
                }

                RetainerTaskResult.Reassign();

                await Coroutine.Wait(5000, () => RetainerTaskAsk.IsOpen);

                if (!RetainerTaskAsk.IsOpen)
                {
                    Log("RetainerTaskAsk didn't open");
                    return(false);
                }

                await Coroutine.Wait(2000, RetainerTaskAskExtensions.CanAssign);

                if (RetainerTaskAskExtensions.CanAssign())
                {
                    RetainerTaskAsk.Confirm();
                }
                else
                {
                    Log($"RetainerTaskAsk Error: {RetainerTaskAskExtensions.GetErrorReason()}");
                    RetainerTaskAsk.Close();
                }

                await Coroutine.Wait(1500, () => DialogOpen || SelectString.IsOpen);

                await Coroutine.Sleep(200);

                if (DialogOpen)
                {
                    Next();
                }
                await Coroutine.Sleep(200);

                await Coroutine.Wait(5000, () => SelectString.IsOpen);
            }
            else
            {
                Log("Venture Not Done");
            }


            return(true);
        }
Example #46
0
 public void MainMenuPlayTransition()
 {
     CleanCoroutine();
     levelCoroutine = StartCoroutine("MainMenuPlayTransitionAnimation");
 }
Example #47
0
 private void PollNext()
 {
     this.routine = StartCoroutine(PollNetwork());
 }
Example #48
0
        IEnumerator transition()
        {
            yield return(Coroutine.waitForSeconds(2f));

            gameManager.Instance.LoadSceneWithTransition(gameManager.Transitions.fade, new titleScene());
        }
Example #49
0
 static private void CancelRoutine(Coroutine routine)
 {
     Instance.StopCoroutine(routine);
 }
Example #50
0
 public void StopCoroutine(Coroutine routine)
 {
     m_mgr.StopCoroutine(routine);
 }
Example #51
0
 protected override void OnEnter()
 {
     AddMessage();
     corTouchCheck     = StartCoroutine(TouchCheck());
     corAnimationCheck = StartCoroutine(AniCheck());
 }
 private void OnEnable()
 {
     ClientConnectionWriter.CommandReceiver.OnDisconnectClient.RegisterResponse(OnDisconnectClient);
     ClientConnectionWriter.CommandReceiver.OnHeartbeat.RegisterResponse(OnHeartbeat);
     heartbeatCoroutine = StartCoroutine(TimerUtils.CallRepeatedly(SimulationSettings.HeartbeatCheckIntervalSecs, CheckHeartbeat));
 }
Example #53
0
 public void Show()
 {
     m_BorderOutlineTransform.localScale = m_BorderOutlineOriginalLocalScale;
     StopCoroutine(ref m_VisibilityCoroutine);
     m_VisibilityCoroutine = StartCoroutine(AnimateVisibility(true));
 }
Example #54
0
 public void Hide()
 {
     StopCoroutine(ref m_VisibilityCoroutine);
     m_VisibilityCoroutine = StartCoroutine(AnimateVisibility(false));
 }
Example #55
0
 public void StartSpawningAgain()
 {
     spawnEnemies = StartCoroutine(SpawnEnemies());
 }
Example #56
0
 public void EndVisuals()
 {
     StopCoroutine(ref m_RotationVisualsCoroutine);
     m_RotationVisualsCoroutine = StartCoroutine(AnimateVisuals(false));
 }
Example #57
0
 private void OnEnable()
 {
     heartbeatCoroutine = StartCoroutine(TimerUtils.CallRepeatedly(SimulationSettings.HeartbeatSendingIntervalSecs, SendHeartbeat));
     SceneManager.UnloadSceneAsync(BuildSettings.SplashScreenScene);
 }
Example #58
0
 public void MoveTo(Vector2 pos, float speed, bool smooth = true)
 {
     StopMoving();
     moving = CharacterManager.instance.StartCoroutine(Moving(pos, speed, smooth));
 }
Example #59
0
 public static CoroutineAsyncBridge GetAwaiter(this Coroutine coroutine)
 {
     return(CoroutineAsyncBridge.Start(coroutine));
 }
    /// <summary>
    /// Called after MatrixManager is initialized
    /// </summary>
    ///
    private void InitEscapeStuff()
    {
        //Primary escape shuttle lookup
        if (PrimaryEscapeShuttle == null)
        {
            var shuttles = FindObjectsOfType <EscapeShuttle>();
            if (shuttles.Length < 1)
            {
                Logger.LogError("Primary escape shuttle is missing from GameManager!", Category.Round);
                return;
            }
            Logger.LogWarning("Primary escape shuttle is missing from GameManager, but one was found on scene");
            primaryEscapeShuttle = shuttles[0];
        }

        //later, maybe: keep a list of all computers and call the shuttle automatically with a 25 min timer if they are deleted

        if (primaryEscapeShuttle.MatrixInfo == null)
        {
            Logger.LogError("Primary escape shuttle has no associated matrix!");
            return;
        }

        //Starting up at Centcom coordinates
        if (GameManager.Instance.QuickLoad)
        {
            if (primaryEscapeShuttle.MatrixInfo == null)
            {
                return;
            }
            if (primaryEscapeShuttle.MatrixInfo.MatrixMove == null)
            {
                return;
            }
        }

        var   orientation = primaryEscapeShuttle.MatrixInfo.MatrixMove.InitialFacing;
        float width;

        if (orientation == Orientation.Up || orientation == Orientation.Down)
        {
            width = PrimaryEscapeShuttle.MatrixInfo.Bounds.size.x;
        }
        else
        {
            width = PrimaryEscapeShuttle.MatrixInfo.Bounds.size.y;
        }

        Vector3 newPos;

        switch (LandingZoneManager.Instance.centcomDocking.orientation)
        {
        case OrientationEnum.Right:
            newPos = new Vector3(LandingZoneManager.Instance.centcomDockingPos.x + Mathf.Ceil(width / 2f), LandingZoneManager.Instance.centcomDockingPos.y, 0);
            break;

        case OrientationEnum.Up:
            newPos = new Vector3(LandingZoneManager.Instance.centcomDockingPos.x, LandingZoneManager.Instance.centcomDockingPos.y + Mathf.Ceil(width / 2f), 0);
            break;

        case OrientationEnum.Left:
            newPos = new Vector3(LandingZoneManager.Instance.centcomDockingPos.x - Mathf.Ceil(width / 2f), LandingZoneManager.Instance.centcomDockingPos.y, 0);
            break;

        default:
            newPos = new Vector3(LandingZoneManager.Instance.centcomDockingPos.x, LandingZoneManager.Instance.centcomDockingPos.y - Mathf.Ceil(width / 2f), 0);
            break;
        }

        PrimaryEscapeShuttle.MatrixInfo.MatrixMove.ChangeFacingDirection(Orientation.FromEnum(PrimaryEscapeShuttle.orientationForDockingAtCentcom));
        PrimaryEscapeShuttle.MatrixInfo.MatrixMove.SetPosition(newPos);
        primaryEscapeShuttle.InitDestination(newPos);

        bool beenToStation = false;

        PrimaryEscapeShuttle.OnShuttleUpdate?.AddListener(status =>
        {
            //status display ETA tracking
            if (status == EscapeShuttleStatus.OnRouteStation)
            {
                PrimaryEscapeShuttle.OnTimerUpdate.AddListener(TrackETA);
            }
            else
            {
                PrimaryEscapeShuttle.OnTimerUpdate.RemoveListener(TrackETA);
                CentComm.UpdateStatusDisplay(StatusDisplayChannel.EscapeShuttle, string.Empty);
            }

            if (status == EscapeShuttleStatus.DockedCentcom && beenToStation)
            {
                Logger.Log("Shuttle arrived at Centcom", Category.Round);
                Chat.AddSystemMsgToChat($"<color=white>Escape shuttle has docked at Centcomm! Round will restart in {TimeSpan.FromSeconds(RoundEndTime).Minutes} minute.</color>", MatrixManager.MainStationMatrix);
                StartCoroutine(WaitForRoundEnd());
            }

            IEnumerator WaitForRoundEnd()
            {
                Logger.Log($"Shuttle docked to Centcom, Round will end in {TimeSpan.FromSeconds(RoundEndTime).Minutes} minute", Category.Round);
                yield return(WaitFor.Seconds(1f));

                EndRound();
            }

            if (status == EscapeShuttleStatus.DockedStation && !primaryEscapeShuttle.hostileEnvironment)
            {
                beenToStation = true;
                SoundManager.PlayNetworked(SingletonSOSounds.Instance.ShuttleDocked);
                Chat.AddSystemMsgToChat($"<color=white>Escape shuttle has arrived! Crew has {TimeSpan.FromSeconds(ShuttleDepartTime).Minutes} minutes to get on it.</color>", MatrixManager.MainStationMatrix);
                //should be changed to manual send later
                departCoroutine = StartCoroutine(SendEscapeShuttle(ShuttleDepartTime));
            }
            else if (status == EscapeShuttleStatus.DockedStation && primaryEscapeShuttle.hostileEnvironment)
            {
                beenToStation = true;
                SoundManager.PlayNetworked(SingletonSOSounds.Instance.ShuttleDocked);
                Chat.AddSystemMsgToChat($"<color=white>Escape shuttle has arrived! The shuttle <color=#FF151F>cannot</color> leave the station due to the hostile environment!</color>", MatrixManager.MainStationMatrix);
            }
        });
    }