示例#1
0
    void Update()
    {
        animator.SetInteger("State", animationState);

        if (animationState == 1)
        {
            shootTime -= Time.deltaTime;

            if (shootTime <= 0)
            {
                shootTime      = shootDuration;
                animationState = 2;
            }
        }

        if (liver != null && liver.Health <= 0)
        {
            Instantiate(Prefabs.Get("HitEffect"), transform.transform.position, Quaternion.identity);
            if (healthUi != null)
            {
                Destroy(healthUi);
            }
            Destroy(gameObject);
        }
    }
示例#2
0
    async void Update()
    {
        tick += Time.deltaTime;

        if (tick > tickDestination)
        {
            currentLetter   = alphabet.Random();
            tick            = 0;
            tickDestination = new FloatRange(1.25f, 5f).RandomValue();
            hex             = ColorUtility.ToHtmlStringRGBA(new Color(
                                                                new FloatRange(0.5f, 1).RandomValue(),
                                                                new FloatRange(0.5f, 1).RandomValue(),
                                                                new FloatRange(0.5f, 1).RandomValue(),
                                                                1
                                                                ));
        }

        pleasePress.text = $"Please press <color=#{hex}>\"{currentLetter}\"</color> to start this experience.";

        foreach (KeyCode vKey in System.Enum.GetValues(typeof(KeyCode)))
        {
            if (Input.GetKey(vKey) && vKey.ToString() == currentLetter && !Game.IsTransitioning)
            {
                await Game.LoadAsync("InsideHome", Prefabs.Get <SceneTransition>("WipeSceneTransition"), 1);

                Instantiate(Prefabs.Get("Camera"));
            }
        }
    }
示例#3
0
    public void Shoot()
    {
        shootTime = shootDuration;

        List <Vector3> directions = !Diagonol ? new List <Vector3>()
        {
            new Vector3(1, 0, 0),
            new Vector3(-1, 0, 0),
            new Vector3(0, 0, 1),
            new Vector3(0, 0, -1),
        } : new List <Vector3>()
        {
            new Vector3(1, 0, 1),
            new Vector3(1, 0, -1),
            new Vector3(-1, 0, 1),
            new Vector3(-1, 0, -1),
        };

        Sounds.Play("Cough", transform.position);

        foreach (Vector3 direction in directions)
        {
            Rigidbody instance = Instantiate(Prefabs.Get("Bullet"), transform.position, Quaternion.identity).GetComponent <Rigidbody>();
            instance.velocity = direction * 10;
        }
    }
示例#4
0
    private void OnTriggerStay(Collider other)
    {
        if (liver == null || liver.IsInvincible)
        {
            return;
        }

        if (other.CompareTag("HurtEnvironment") || other.CompareTag("HurtPlayer"))
        {
            scene.fight = true;

            Player player = other.GetComponentInParent <Player>();
            if (player != null)
            {
                player.LandedHit(gameObject);
            }
            else
            {
                IHurter hurter = other.GetComponent <IHurter>();
                if (hurter != null)
                {
                    hurter.LandedHit(gameObject);
                }
            }

            animator.SetInteger("State", 2);

            liver.TakeDamage(1);
            Instantiate(Prefabs.Get("HitEffect"), transform.transform.position, Quaternion.identity);
            Vector3 direction = other.transform.position - transform.position;
            direction.Normalize();
        }
    }
示例#5
0
    public void DropLoot()
    {
        if (dropped)
        {
            return;
        }

        var coins = Random.Range(config.MinCoins, config.MaxCoins + 1);

        for (var i = 0; i < coins; i++)
        {
            var coin = Prefabs.Get <Coin>();
            coin.transform.position = transform.position;
        }

        var hearts = Random.Range(config.MinHearts, config.MaxHearts + 1);

        for (var i = 0; i < hearts; i++)
        {
            var heart = Prefabs.Get <Heart>();
            heart.transform.position = transform.position;
        }

        dropped = true;
    }
示例#6
0
    void Start()
    {
        Sounds.Play("Wind", null, true);

        Camera.main.transform.position    = target1.transform.position;
        Camera.main.transform.eulerAngles = target1.transform.eulerAngles;
        texts  = startUi.GetComponentsInChildren <TextMeshProUGUI>().ToList();
        player = FindObjectOfType <Player>();
        player.gameObject.SetActive(false);
        signTrigger.Execute = (_) =>
        {
            Note.SetActive(true);
            noteCooldown = 0.25f;
        };
        signTrigger.OnExit = (_) =>
        {
            Note.SetActive(false);
        };
        EntranceTrigger.OnEnter = (Collider other) =>
        {
            if (other.CompareTag("Player"))
            {
                _ = Game.LoadAsync("Cave", Prefabs.Get <SceneTransition>("FadeSceneTransition"));
            }
        };
    }
示例#7
0
 private async void ExitTriggered(object source, TriggerEnterEventArgs args)
 {
     if (args.Other.CompareTag("Player"))
     {
         Game.LoadAsync("Exit", Prefabs.Get <SceneTransition>("FadeSceneTransition"));
     }
 }
示例#8
0
文件: GameStart.cs 项目: Juutis/AKJ9
    void Start()
    {
        BaseTower baseTower = Prefabs.Instantiate <BaseTower>();

        baseTower.transform.position = Vector3.zero;

        Energy energy = Prefabs.Instantiate <Energy>();

        energy.transform.position = new Vector3(0f, 0f, 5f);

        Tower tower = Prefabs.Instantiate <Tower>();

        tower.transform.position = new Vector3(5f, 0f, 5f);
        Tower tower2 = Prefabs.Instantiate <Tower>();

        tower2.transform.position = new Vector3(7f, 0f, 7f);

        GameObject goblin = Prefabs.Get <Goblin>();

        for (int i = 0; i < 10; i += 1)
        {
            GameObject newGoblin = Instantiate(goblin, tower.transform.position, Quaternion.identity);
            Vector2    rnd       = Random.insideUnitCircle.normalized * 5f;
            newGoblin.transform.Translate(new Vector3(rnd.x, 0f, rnd.y), Space.World);
        }
    }
示例#9
0
    // ---

    void Start()
    {
        rigidbody      = GetComponent <Rigidbody>();
        collider       = GetComponent <CapsuleCollider>();
        animator       = GetComponent <Animator>();
        liver          = GetComponent <Liver>();
        trigger        = GetComponentInChildren <Trigger>();
        trigger.OnStay = OnChildTriggerStay;
        camera         = Camera.main.transform;
        startGravity   = Gravity;

        liver.Health = Game.PlayerHealth ?? liver.Health;
        potionCount  = Game.PotionCount ?? potionCount;

        if (SceneManager.GetActiveScene().name != "OutsideCave")
        {
            var ui = Instantiate(Prefabs.Get("PlayerUi"), GameObject.FindGameObjectWithTag("Canvas").transform);

            liver.SetUi(GameObject.FindGameObjectWithTag("PlayerUiPanel").GetComponent <RectTransform>());
            potionCountUi = GameObject.FindGameObjectWithTag("PotionUiText").GetComponent <TextMeshProUGUI>();
        }

        start  = NormalStart;
        update = NormalUpdate;
        exit   = NormalExit;

        if (Game.spawnPosition != null)
        {
            transform.position = Game.spawnPosition.Value;
            Game.spawnPosition = null;
        }
    }
    // We don't have to fiddle with a 'Hand' instance in this case since this is the enemy.
    // We just trust and render whatever the master client sends us.
    void UpdateEnemyCards(int ammount)
    {
        // Only makes sense if this is the enemy's hand
        Assert.IsTrue(side.owner == Owner.ENEMY);

        int numberOfCardsInEnemyHand = transform.childCount;

        // No work needed if the total cards remain the same.
        if (numberOfCardsInEnemyHand == ammount)
        {
            return;
        }

        // We have to remove cards
        if (numberOfCardsInEnemyHand > ammount)
        {
            for (int i = numberOfCardsInEnemyHand - 1; i >= ammount; i--)
            {
                Destroy(myTransform.GetChild(i).gameObject);
            }
        }
        else
        {
            // We have to add cards
            int            add           = ammount - numberOfCardsInEnemyHand;
            CardGUI_canvas cardGUIPrefab = Prefabs.Get("cardGUI_canvas").GetComponent <CardGUI_canvas>();

            for (int i = 0; i < add; i++)
            {
                CardGUI_canvas cardCpy = Instantiate(cardGUIPrefab, myTransform);
                cardCpy.Location = CardLocation.ENEMY_HAND;
            }
        }
    }
示例#11
0
 void Update()
 {
     if (liver != null && liver.Health <= 0)
     {
         Instantiate(Prefabs.Get("HitEffect"), transform.transform.position, Quaternion.identity);
         Destroy(gameObject);
     }
 }
            public static void ShowDamage(string creatureId, int damageAmount, string bloodColor, float rotationOffset = 0)
            {
                CreatureBoardAsset creatureAsset = GetCreatureBoardAsset(creatureId);

                if (creatureAsset == null)
                {
                    Log.Error($"ShowDamage - creatureId {creatureId} not found.");
                    return;
                }

                if (damageAmount > 30)
                {
                    ShowDamage(creatureId, damageAmount - 30, bloodColor, random.NextInt(60) - 30);
                    damageAmount = 30;
                }

                float scale = 0.65f * creatureAsset.CreatureScale;                  // 0.5, 1, 2, 3, 4

                string prefabName;
                float  scaleMultiplier;

                if (damageAmount < 15)
                {
                    prefabName      = GetRandomSmallBloodPrefab();
                    scaleMultiplier = 1;
                }
                else
                {
                    prefabName      = GetRandomLargeBloodPrefab();
                    scaleMultiplier = 1 + damageAmount / 70f;
                }

                Log.Debug($"prefabName = \"{prefabName}\"");
                GameObject bloodPrefab = Prefabs.Get(prefabName);

                if (bloodPrefab == null)
                {
                    Log.Error($"Prefab \"{prefabName}\" not found!");
                    bloodPrefab = Prefabs.Get("Blood4");
                }

                // TODO: Change the blood color... bloodColor

                scale *= scaleMultiplier;

                float groundHeight = creatureAsset.GetGroundHeight();

                //Log.Debug($"groundHeight = {groundHeight}");

                GameObject bloodEffect = UnityEngine.Object.Instantiate(bloodPrefab, creatureAsset.HookHitTarget.position, creatureAsset.HookHitTarget.rotation);

                Property.ModifyFloat(bloodEffect, null, "<BFX_BloodSettings>.GroundHeight", groundHeight);
                ChangeBloodEffectColor(bloodEffect, bloodColor);
                bloodEffect.transform.Rotate(Vector3.up, 180 + rotationOffset);
                bloodEffect.transform.localScale = new Vector3(scale, scale, scale);

                Instances.AddTemporal(bloodEffect, 16);
            }
示例#13
0
    public void TakeUp(string cardId)
    {
        CardGUI_canvas cardGUIPrefab = Prefabs.Get("cardGUI_canvas").GetComponent <CardGUI_canvas>();

        CardGUI_canvas cardCpy = Instantiate(cardGUIPrefab, myTransform);

        cardCpy.CardId   = cardId;
        cardCpy.Location = CardLocation.GAME;
    }
示例#14
0
 void Awake()
 {
     if (!GameObject.Find("_Core"))
     {
         var core = Instantiate(Core);
         core.name = Core.name;
         Instantiate(Prefabs.Get("Camera"));
     }
 }
示例#15
0
    void Barf()
    {
        Vector3 direction = player.transform.position - transform.position;

        direction.Normalize();
        Rigidbody instance = Instantiate(Prefabs.Get("Bullet"), transform.position, Quaternion.identity).GetComponent <Rigidbody>();

        instance.velocity = direction * 10;
        Sounds.Play("Cough", transform.position);
    }
示例#16
0
    void Awake()
    {
        main           = this;
        popupContainer = this.FindChildObject("container").GetComponent <Transform>();
        EventSystem eventSystem = GameObject.FindObjectOfType <EventSystem>();

        if (eventSystem == null)
        {
            Prefabs.Get <EventSystem>();
        }
    }
示例#17
0
    public void Init(AudioClip clip, float volume = 1f)
    {
        Clip = clip;
        AudioSource source = Prefabs.Get <AudioSource>();

        source.clip   = clip;
        source.volume = volume;
        source.transform.SetParent(transform);
        customVolume = volume;
        audioSources.Add(source);
    }
示例#18
0
    void Start()
    {
        liver     = GetComponent <Liver>();
        rigidbody = GetComponent <Rigidbody>();
        animator  = GetComponentInChildren <Animator>();

        healthUi = Instantiate(Prefabs.Get("EnemyHP"), GameObject.FindGameObjectWithTag("Canvas").transform);
        healthUi.GetComponent <UiFollow>().target = hpTarget.transform;
        healthUi.SetActive(false);
        liver.SetUi(healthUi.GetComponentInChildren <HpBar>().GetComponent <RectTransform>());
    }
    // In this case we have to add the cards to the hand instance since this is our hand.
    void UpdatePlayerCards(Card[] cardsToAdd)
    {
        Assert.IsTrue(side.owner == Owner.PLAYER);
        CardGUI_canvas cardGUIPrefab = Prefabs.Get("cardGUI_canvas").GetComponent <CardGUI_canvas>();

        for (int i = 0; i < cardsToAdd.Length; i++)
        {
            CardGUI_canvas cardGUI = Instantiate(cardGUIPrefab, myTransform);
            cardGUI.Location = CardLocation.PLAYER_HAND;
            cardGUI.CardId   = cardsToAdd[i].Id;
        }
    }
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            prompt = Instantiate(Prefabs.Get("Prompt"), canvas.transform);
        }

        if (other.CompareTag("Player") && OnEnter != null)
        {
            OnEnter(other);
        }
    }
示例#21
0
    private void PlayClip(AudioClip clip, float volume = 1f)
    {
        GameSoundSource source = soundSources.Find(sound => sound.Clip == clip);

        if (source == null)
        {
            source = Prefabs.Get <GameSoundSource>();
            source.transform.SetParent(transform);
            source.Init(clip, volume);
            soundSources.Add(source);
        }
        source.Play();
    }
示例#22
0
    public void Play()
    {
        AudioSource source = audioSources.Find(source => !source.isPlaying);

        if (source == null)
        {
            source = Prefabs.Get <AudioSource>();
            source.transform.SetParent(transform);
            source.clip   = Clip;
            source.volume = customVolume;
            audioSources.Add(source);
        }
        source.Play();
    }
示例#23
0
    private void OnTriggerStay(Collider other)
    {
        if (liver == null || liver.IsInvincible)
        {
            return;
        }

        if (other.CompareTag("HurtEnvironment") || other.CompareTag("HurtPlayer"))
        {
            Player player = other.GetComponentInParent <Player>();
            if (player != null)
            {
                player.LandedHit(gameObject);
            }
            else
            {
                IHurter hurter = other.GetComponent <IHurter>();
                if (hurter != null)
                {
                    hurter.LandedHit(gameObject);
                }
            }

            ChangeState(FlyingHeadState.Hurt);

            liver.TakeDamage(1);
            Instantiate(Prefabs.Get("HitEffect"), transform.transform.position, Quaternion.identity);
            Vector3 direction = other.transform.position - transform.position;
            direction.y = 0;
            direction.Normalize();
            rigidbody.AddForce(-direction * 450);

            if (healthUi != null)
            {
                healthUi.SetActive(true);
                if (healthUiTimer != null)
                {
                    Destroy(healthUiTimer.gameObject);
                }
                healthUiTimer = Timer.Create(1f, () =>
                {
                    if (healthUi != null)
                    {
                        healthUi.SetActive(false);
                    }
                });
            }
        }
    }
示例#24
0
    void Start()
    {
        promptedTrigger = GetComponentInChildren <PromptedTrigger>();
        animator        = GetComponentInChildren <Animator>();
        collider        = GetComponentInChildren <BoxCollider>();

        promptedTrigger.Accepted += (object source, bool hit) => {
            var effect = Game.New(Prefabs.Get("SimpleEffect"));
            effect.transform.position = Game.Player.transform.position;

            animator.SetInteger("State", 1);
            Sound.Play("WoodFalling", true, 0.25f);
            Game.CutGrassCount += 1;
        };
    }
示例#25
0
    private void OnChildTriggerStay(Collider other)
    {
        if (liver.IsInvincible || isDodgeInvincible)
        {
            return;
        }

        if (other.CompareTag("HurtEnvironment") || other.CompareTag("HurtEnemy"))
        {
            ChangeState(PlayerState.Hurt);
            Instantiate(Prefabs.Get("HitEffect"), transform.transform.position, Quaternion.identity);
            liver.TakeDamage(1, other.gameObject);
            Game.PlayerHealth = liver.Health;
        }
    }
示例#26
0
 public void ShowPopup(string title, string message)
 {
     if (!canShowPopup)
     {
         return;
     }
     PauseMenuCanBeOpened = false;
     optionsButton.SetActive(false);
     upgradeUI.HideToggle();
     fader.FadeIn(delegate {
         UIPopup uiPopup = Prefabs.Get <UIPopup>();
         uiPopup.Init(popupContainer, this);
         uiPopup.Show(title, message);
     });
 }
示例#27
0
    void RenderShipSlots(int slots)
    {
        slotSpaceshipPanel.SetActive(true);

        Transform slotsTransf = slotSpaceshipPanel.transform;

        slotsTransf.DestroyAllChildren();

        GameObject slotGUIPrefab = Prefabs.Get("SlotGUI_canvas");

        for (int i = 0; i < slots; i++)
        {
            Instantiate(slotGUIPrefab, slotsTransf);
        }
    }
示例#28
0
    void RenderShields(int shields)
    {
        shieldsPanel.SetActive(true);

        Transform shieldTransf = shieldsPanel.transform;

        shieldTransf.DestroyAllChildren();

        GameObject shieldGUIPrefab = Prefabs.Get("ShieldGUI_canvas");

        for (int i = 0; i < shields; i++)
        {
            Instantiate(shieldGUIPrefab, shieldTransf);
        }
    }
示例#29
0
    // Update is called once per frame
    void Update()
    {
        animator.SetInteger("State", (int)animationState);
        update();

        if (liver != null && liver.Health <= 0)
        {
            Instantiate(Prefabs.Get("HitEffect"), transform.transform.position, Quaternion.identity);
            if (healthUi != null)
            {
                Destroy(healthUi);
            }
            Destroy(gameObject);
        }
    }
示例#30
0
    public static async Task Single(TextBoxModel model)
    {
        if (instance != null)
        {
            Destroy(instance.gameObject);
        }

        model.CloseWhenDone = true;

        var prefab  = Prefabs.Get("TextBox");
        var go      = Game.NewCanvasElement(prefab);
        var textBox = go.GetComponent <TextBox>();

        instance = textBox;
        await textBox.ExecuteAsync(model);

        await new WaitForUpdate();
    }