Esempio n. 1
0
    public override void ApplyToMap(Vector3Int position)
    {
        if (Random.value < 0.75f || CurrentRunData.Instance.FloorInWorld == 1)
        {
            gameObject.SetActive(false);
            return;
        }

        Vector3 worldPosition = new Vector3(MapBuilder.MapMaxWidth / 2, MapBuilder.MapMaxHeight / 2);

        if (Random.value < 0.5f)
        {
            float val = Random.value;
            if (val < 0.5f)
            {
                var p = MapUtil.GetLeftmostFreeCell();
                p.y          += 5;
                p.x          -= 4;
                worldPosition = p;
            }
            else
            {
                var p = MapUtil.GetRightmostFreeCell();
                p.y          += 5;
                p.x          += 4;
                worldPosition = p;
            }
        }

        PlayerInfoScript.Instance.ShowInfo("A Gift");

        transform.position = worldPosition;
        ApplyTilemap(new Vector3Int((int)worldPosition.x, (int)worldPosition.y, 0));
    }
Esempio n. 2
0
    IEnumerator <float> AppearCo()
    {
        yield return(Timing.WaitForSeconds(appearMin_ + Random.value * appearRandom_));

        PlayerInfoScript.Instance.ShowInfo("A Horrifying Sound Is Heard In The Distance", Color.red);

        AudioManager.Instance.PlaySfxClip(AppearSound, maxInstances: 3);
        yield return(Timing.WaitForSeconds(4));

        var     playerPos = AiBlackboard.Instance.PlayerPosition;
        Vector3 appearPos;

        if (playerPos.x > MapBuilder.WorldCenter.x)
        {
            appearPos = MapUtil.GetRightmostFreeCell();
        }
        else
        {
            appearPos = MapUtil.GetLeftmostFreeCell();
        }

        AudioManager.Instance.PlaySfxClip(SceneGlobals.Instance.AudioManager.AudioClips.PlayerLand, 1, 0.1f);
        Activate(true);

        var   startOffset = new Vector3(0, 1, -12);
        float t           = 1;

        while (t >= 0)
        {
            CameraShake.Instance.SetMinimumShake(1.0f);

            var pos = appearPos + startOffset * t;
            transform_.SetPositionAndRotation(pos, Quaternion.Euler(0, 0, t * 500));

            t -= Time.unscaledDeltaTime * 2;
            yield return(0);
        }

        transform_.SetPositionAndRotation(appearPos, Quaternion.identity);
        MapScript.Instance.TriggerExplosion(appearPos, 2.5f);

        PlayerInfoScript.Instance.ShowInfo($"{me_.Name} Has Arrived!", Color.red);

        aiCoHandle_ = Timing.RunCoroutine(AICo().CancelWith(this.gameObject));
    }