Example #1
0
        public Part(Entity e, int PartItem, int Col, int Row) : base(e, PartItem, Col, Row)
        {
            Flying   = true;
            Dragging = false;
            Type     = "Part";
            curCol   = Col;
            curRow   = Row;

            MyType   = PartItem;
            Attached = true;

            rotationOffSet = 0;

            int   A = (32 * Col) * (32 * Col);
            int   B = (32 * Row) * (32 * Row);
            float C = (float)Math.Sqrt(A + B);

            Distance = C;
            angle    = (float)Math.Atan2(Col, Row) * (180 / (float)Math.PI);
            PartNum  = PartItem;
            myShip   = e as BaseShip;

            myShip.shipParts.Add(this);
            if (PartItem == 1)
            {
                EquipSfx.Play();
                Image Hull = new Image(Library.GetTexture("MetalPlating.png"));
                aPart = Hull;
                AddGraphic(aPart);
                SetHitboxTo(aPart);
                totalHealth = health = 150;
            }
            else if (PartItem == 2)
            {
                EquipSfx.Play();
                Image Thruster = new Image(Library.GetTexture("Thruster.png"));
                aPart = Thruster;
                AddGraphic(aPart);
                SetHitboxTo(aPart);
                totalHealth = health = 100;
            }
            else if (PartItem == 3)
            {
                EquipSfx.Play();
                Image Turret = new Image(Library.GetTexture("Turret.png"));
                aPart = Turret;

                totalHealth = health = 50;
                AddGraphic(aPart);
                SetHitboxTo(aPart);
            }



            X = 100;
            Y = 100;
        }
Example #2
0
    IEnumerator Message(bool accessGranted, bool loopForever)
    {
        showingMessage = true;
        mainScreen.SetActive(false);
        GameObject m = (accessGranted) ? granted : denied;
        int        i = 3;

        while (i > 0 || loopForever)
        {
            i--;
            yield return(new WaitForSeconds(.2f));

            m.SetActive(true);
            if (!accessGranted)
            {
                Sfx.Play(deniedAudio, Mathf.Lerp(.8f, .3f, 1 - i / 3f));
            }
            yield return(new WaitForSeconds(.5f));

            m.SetActive(false);
        }

        if (!accessGranted)
        {
            hintsUI.text += "\n" + fullHintsTxt.Split('\n')[3 - attemptsRemaining];
        }

        m.SetActive(false);
        mainScreen.SetActive(true);
        showingMessage = false;
    }
Example #3
0
 public void TakeAir()
 {
     canTakeAir = false;
     HasTookAir = true;
     (Sprite as AnimatedSprite).Change("TakeAir");
     Sfx.Play("pegar_ar");
 }
Example #4
0
    IEnumerator RestartSequence(float delay)
    {
        Sfx.Play(restartAudio);
        numRestarts++;
        FindObjectOfType <Stan>().OnTaskFail();
        yield return(new WaitForSeconds(delay));

        float p            = 0;
        bool  hasResetGame = false;

        while (p < 1)
        {
            p += Time.deltaTime * .75f;
            // float brightnessPercent = Mathf.Clamp01(restartBrightnessCurve.Evaluate(p));
            float brightnessPercent = Mathf.Clamp01(-(p * 2 - 1) * (p * 2 - 1) + 1);
            //print(p+"  " + brightnessPercent);
            monitor.material.SetColor("_EmissionColor", Color.white * brightnessPercent * 3);
            //screenOverlayMat.color = new Color(1, 1, 1, p);
            screenOverlay.material.color = new Color(1, 1, 1, brightnessPercent);
            if (p >= .5f && !hasResetGame)
            {
                Destroy(currentTask.gameObject);
                hasResetGame = true;
            }
            yield return(null);
        }
        screenOverlay.material.color = Color.clear;

        OnRestartComplete();
    }
Example #5
0
 public void PlayTaskFailSfx(int i)
 {
     if (taskFailSfx != null && i < taskFailSfx.Length)
     {
         Sfx.Play(taskFailSfx[i]);
     }
 }
Example #6
0
        protected override IEnumerator OnDeath(Object killer)
        {
            yield return(base.OnDeath(killer));

            StartCoroutine(Bgm.Stop(0.5f));
            Sfx.Play(DeathSfxId);
            ChangeSprite("entity.player.drown");
            var targetY = transform.position.y + 300;


            charaGravityScale = 0;

            UpdateUI();

            for (int y = (int)transform.position.y; y < targetY; y += 4)
            {
                transform.Rotate(Vector3.forward * 180 * Time.deltaTime);
                transform.position = new Vector3(transform.position.x, y, transform.position.z);

                yield return(null);
            }
            yield return(new WaitForSeconds(2.5f));

            Wyte.Initalize();
        }
Example #7
0
    void Eat(GameObject food)
    {
        if (!dead)
        {
            if (OnEat != null)
            {
                OnEat();
            }
            Sfx.Play(eatSfx[Random.Range(0, eatSfx.Length)], .75f);
            Destroy(food);
            //GrowSnake();
            for (int i = 0; i < numToGrowByPerFood; i++)
            {
                if (visIndex < maxLength)
                {
                    snake[visIndex].SetVisible(true);
                    growingParts.Add(snake[visIndex].t);
                    snake[visIndex].t.localScale = Vector3.zero;
                    snake[visIndex].t.GetComponent <CircleCollider2D>().enabled = false;
                }
                visIndex++;
            }

            numEaten++;
        }
    }
Example #8
0
 public void MouseEnter()
 {
     if (!Disabled)
     {
         Sfx.Play(Sfx.ID.BUTTON_MOUSEOVER);
     }
 }
Example #9
0
    IEnumerator StartUpRoutine()
    {
        while (Time.time < fadeTime)
        {
            float fadePercent = Time.time / fadeTime;
            fadePlane.color = Color.Lerp(Color.black, Color.clear, fadePercent);
            yield return(null);
        }

        readyToSkip = true;

        yield return(new WaitForSeconds(.5f));

        while (titleAnimIndex < titleAnim.Length)
        {
            title.text = titleAnim[titleAnimIndex].text;
            titleAnimIndex++;
            Sfx.Play(keyAudio[Random.Range(0, keyAudio.Length)]);

            if (titleAnimIndex < titleAnim.Length)
            {
                yield return(new WaitForSeconds(titleAnim[titleAnimIndex].delay));
            }
        }
        textRoutine = StartCoroutine(ShowExtraText());
    }
Example #10
0
        private void PlaceEquipment()
        {
            Item item = null;

            if (!this._billboardRotate)
            {
                InventoryItemView inventoryItemView = LocalPlayer.Inventory.IsRightHandEmpty() ? null : LocalPlayer.Inventory.RightHand;
                if (inventoryItemView != null)
                {
                    item = inventoryItemView.ItemCache;
                }
            }
            else
            {
                item = ItemDatabase.Items[this._currentAddItem];
            }
            if (item != null && this.IsValidItem(item))
            {
                if (LocalPlayer.Inventory.IsRightHandEmpty() || LocalPlayer.Inventory.RightHand._itemId != item._id || LocalPlayer.Inventory.IsSlotLocked(Item.EquipmentSlot.RightHand))
                {
                    if (!LocalPlayer.Inventory.RemoveItem(item._id, 1, false, true))
                    {
                        return;
                    }
                }
                else if (!LocalPlayer.Inventory.ShuffleRemoveRightHandItem())
                {
                    return;
                }
                if (BoltNetwork.isRunning && !this.hellDoorSlot)
                {
                    RackAdd rackAdd = RackAdd.Create(GlobalTargets.OnlyServer);
                    rackAdd.Slot   = base.GetComponentInParent <CoopRack>().GetSlotIndex(this);
                    rackAdd.Rack   = base.GetComponentInParent <BoltEntity>();
                    rackAdd.ItemId = item._id;
                    rackAdd.Send();
                }
                else
                {
                    if (this.hellDoorSlot)
                    {
                        this.Removed = false;
                        this.Added   = true;
                    }
                    this._storedItemId = item._id;
                    this.SpawnItemView();
                }
                Sfx.Play(SfxInfo.SfxTypes.AddItem, base.transform, true);
                this._addIcon.gameObject.SetActive(false);
                if (!this._offsetIcons)
                {
                    this._addIcon.transform.parent.position = base.transform.position;
                }
                else
                {
                    this._takeIcon.transform.parent.position = base.transform.position + this.IconsOffset;
                }
            }
        }
Example #11
0
 void OnCorrectPassword()
 {
     Sfx.Play(acceptedAudio);
     StartCoroutine(Message(true, true));
     TaskCompleted();
     FindObjectOfType <Sequencer>().GameWin();
     StartCoroutine(ShowWin());
 }
Example #12
0
 public void MusicPlay()
 {
     screenOverlay.material.color = Color.clear;
     musicSource.clip             = music;
     musicSource.volume           = 1;
     musicSource.Play();
     Sfx.Play(keySlam);
 }
 void Update()
 {
     if (Input.GetButtonDown("Fire"))
     {
         weapon.Fire(transform.parent.position, transform.parent.rotation);
         sfx.Play();
     }
 }
Example #14
0
        private void StickContentUpdate(ref MultiHolder.ContentTypes showAddIcon)
        {
            bool flag     = true;
            bool takeIcon = false;

            if ((!BoltNetwork.isRunning && this._contentActual > 0) || (BoltNetwork.isRunning && this._contentActual > 0 && flag))
            {
                takeIcon = true;
                if (TheForest.Utils.Input.GetButtonDown("Take"))
                {
                    if (BoltNetwork.isRunning)
                    {
                        ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(GlobalTargets.OnlyServer);
                        itemHolderTakeItem.ContentType = (int)this._contentTypeActual;
                        itemHolderTakeItem.Target      = base.entity;
                        itemHolderTakeItem.Player      = LocalPlayer.Entity;
                        itemHolderTakeItem.Send();
                    }
                    else if (LocalPlayer.Inventory.AddItem(this.StickItemId, 1, false, false, null) || LocalPlayer.Inventory.FakeDrop(this.StickItemId, null))
                    {
                        this.StickRender[this._contentActual - 1].SetActive(false);
                        this._contentActual--;
                        if (this._contentActual == 0)
                        {
                            takeIcon = false;
                            this._contentTypeActual = MultiHolder.ContentTypes.None;
                        }
                        this.RefreshMassAndDrag();
                    }
                }
            }
            if (this._contentActual < this.StickRender.Length && LocalPlayer.Inventory.Owns(this.StickItemId, true) && flag && (this._content == MultiHolder.ContentTypes.Stick || this._addingContentType == MultiHolder.ContentTypes.Stick))
            {
                showAddIcon = MultiHolder.ContentTypes.Stick;
                if (TheForest.Utils.Input.GetButtonDown("Craft"))
                {
                    LocalPlayer.Inventory.RemoveItem(this.StickItemId, 1, false, true);
                    Sfx.Play(SfxInfo.SfxTypes.AddLog, this.StickRender[this._contentActual].transform, true);
                    if (BoltNetwork.isRunning)
                    {
                        ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                        itemHolderAddItem.ContentType = 4;
                        itemHolderAddItem.Target      = base.entity;
                        itemHolderAddItem.Send();
                    }
                    else
                    {
                        this._contentTypeActual = MultiHolder.ContentTypes.Stick;
                        this._contentActual++;
                        this.StickRender[this._contentActual - 1].SetActive(true);
                        this.RefreshMassAndDrag();
                    }
                }
            }
            Scene.HudGui.HolderWidgets[0].Show(takeIcon, this._contentTypeActual == MultiHolder.ContentTypes.Stick && showAddIcon == MultiHolder.ContentTypes.Stick, this.TakeIcon.transform);
        }
Example #15
0
 public void Show()
 {
     if (IsVisible)
     {
         return;
     }
     Sfx.Play("system.menu.open");
     Wyte.IsNotFreezed = false;
     IsVisible         = true;
 }
Example #16
0
 public void Hide()
 {
     if (!IsVisible)
     {
         return;
     }
     Sfx.Play("system.menu.close");
     Wyte.IsNotFreezed = true;
     IsVisible         = false;
 }
Example #17
0
 /// <summary>
 /// ジャンプした時
 /// </summary>
 public virtual void Jump()
 {
     if (IsGrounded())
     {
         var nowVec = Velocity;
         Velocity  = new Vector3(nowVec.x, charaJumpScale);
         IsJumping = true;
         Sfx.Play(JumpSfxId);
     }
 }
Example #18
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.CompareTag("Player"))
     {
         Health playerHealth  = collision.gameObject.GetComponent <Health>();
         Sfx    playerHurtSfx = collision.gameObject.GetComponent <Sfx>();
         playerHurtSfx.Play();
         playerHealth.Damage(stats.attack);
         healthKeeper.UpdateText();
     }
 }
Example #19
0
    IEnumerator GameLoseSequence()
    {
        Sfx.Play(gameOverSirens);
        float endDuration = gameOverSirens.length;
        float speed       = (1 / .7f);
        Color themeCol    = Color.red;

        yield return(new WaitForSeconds(.2f));

        bool  s             = false;
        float t             = 0;
        bool  hasPlayedBeep = false;

        while (t < endDuration)
        {
            if (t > 1 && !readyForGameReload)
            {
                readyForGameReload = true;
            }
            if (t > 8 && !s)
            {
                s = true;
                FindObjectOfType <Stan>().SayWithText("press any key to return to menu", null);
            }

            float p = Mathf.Repeat(t * speed, 1);
            t += Time.deltaTime;
            float brightnessPercent = Mathf.Clamp01(-(p * 2 - 1) * (p * 2 - 1) + 1);
            //print(p+"  " + brightnessPercent);
            monitor.material.SetColor("_EmissionColor", themeCol * brightnessPercent * 3);
            //screenOverlayMat.color = new Color(1, 1, 1, p);
            screenOverlay.material.color = new Color(1, 1, 1, brightnessPercent);

            if (p > .3f && !hasPlayedBeep)
            {
                Sfx.Play(endBeepAudio);
                hasPlayedBeep = true;
            }
            if (p < .3f)
            {
                hasPlayedBeep = false;
            }

            if (t + 3 > endDuration)
            {
                float fadePercent = Mathf.InverseLerp(endDuration - 3, endDuration, t);
                fadePlane.color = Color.Lerp(Color.clear, Color.black, fadePercent);
            }

            yield return(null);
        }
        UnityEngine.SceneManagement.SceneManager.LoadScene(0);
    }
Example #20
0
        static void PlayKilledSound(NPC n)
        {
            if (n.P_SoundOnDeath as SfxRef != null)
            {
                var r = (SfxRef)n.P_SoundOnDeath;

                Sfx.Play(r.Resolve(), n.position, r.VariantID);
            }
            else if (n.soundKilled > 0)
            {
                Sfx.Play(VanillaSfxes.NpcKilled, n.position, n.soundKilled);
            }
        }
Example #21
0
    void Start()
    {
        anim = GetComponent <Animator>();

        int[] failIndices = new int[numFailAnims];
        for (int i = 0; i < numFailAnims; i++)
        {
            failIndices[i] = i;
        }
        Utility.Shuffle(failIndices);
        failAnimIndexQueue = new Queue <int>(failIndices);
        Sfx.Play(chairRoll);
    }
Example #22
0
        static void PlayUseSound(Item i, Player p)
        {
            if (i.P_UseSound as SfxRef != null)
            {
                var r = (SfxRef)i.P_UseSound;

                Sfx.Play(r.Resolve(), p.position, r.VariantID);
            }
            else if (i.useSound > 0)
            {
                Sfx.Play(VanillaSfxes.UseItem, p.position, i.useSound);
            }
        }
Example #23
0
        static void PlayHitSound(NPC n)
        {
            if (n.P_SoundOnHit as SfxRef != null)
            {
                var r = (SfxRef)n.P_SoundOnHit;

                Sfx.Play(r.Resolve(), n.position, r.VariantID);
            }
            else if (n.soundHit > 0)
            {
                Sfx.Play(VanillaSfxes.NpcHit, n.position, n.soundHit);
            }
        }
Example #24
0
    void OnWordSucceeded(string w)
    {
        numLettersTyped  += w.Length;
        totalTypeTime    += (Time.time - wordStartTime);
        recordingWordTime = false;
        // print(TypeSpeed);

        spawnedFirst  = false;
        spawnedSecond = false;
        numWordsDone++;
        requestedVoice = false;
        Sfx.Play(wordCompleteAudio, .2f);

        inputString = "";
    }
Example #25
0
        public IEnumerator Say(string sprite, params string[] args)
        {
            var messageSource = I18n[NovelHelper.CombineAll(args)];
            var voice         = "system.saying";

            // 話者がいる場合は表示
            // hack 今後もっとUIをよくする
            buffer        = string.IsNullOrEmpty(sprite) ? "" : sprite + " : ";
            messageSource = TextUtility.RemoveTags(messageSource);
            TextElement[] mes;
            try
            {
                mes = new TextComponent(messageSource).Elements;
            }
            catch (FormatException ex)
            {
                mes = new TextComponent(string.Format(I18n["fts.error"], TextUtility.ToSafeString(ex.Message))).Elements;
            }
            foreach (var c in mes)
            {
                if (c.WaitTime > 0)
                {
                    yield return(new WaitForSeconds(c.WaitTime));
                }

                if (c.Nod)
                {
                    yield return(Nod());
                }

                if (!string.IsNullOrWhiteSpace(c.Voice))
                {
                    voice = c.Voice;
                }

                buffer += c.ToString();
                if (!quickEnabled && c.Speed != 0)
                {
                    Sfx.Play(voice);
                    // タッチ時は早くする
                    yield return(new WaitForSeconds(speed / Mathf.Abs(c.Speed) / (IsTouched ? 2 : 1)));
                }
            }

            yield return(Nod());

            buffer = "";
        }
Example #26
0
    IEnumerator ShowExtraText()
    {
        yield return(new WaitForSeconds(1));

        string targetString = subtitle.text;

        subtitle.text = "";
        subtitle.gameObject.SetActive(true);

        for (int i = 0; i < targetString.Length; i++)
        {
            Sfx.Play(keyAudio[Random.Range(0, keyAudio.Length)], .4f);

            subtitle.text += targetString[i];
            yield return(new WaitForSeconds(Random.Range(.025f, .035f)));
        }

        yield return(new WaitForSeconds(1));

        //targetString= instruction.text;
        //instruction.text = "";
        instruction.gameObject.SetActive(true);

        /*
         *      for (int i = 0; i < targetString.Length; i++)
         *      {
         *              instruction.text += targetString[i];
         *              yield return new WaitForSeconds(.03f);
         *      }
         */
        while (!keyPressed)
        {
            for (int i = 0; i < 3; i++)
            {
                yield return(new WaitForSeconds(.2f));

                instruction.text += ".";
            }
            yield return(new WaitForSeconds(.4f));

            instruction.text = instruction.text.Substring(0, instruction.text.Length - 3);
            yield return(new WaitForSeconds(.4f));
        }
    }
Example #27
0
 void OnDeath()
 {
     if (!dead)
     {
         if (OnDeathEvent != null)
         {
             OnDeathEvent();
         }
         Sfx.Play(deathSfx, .2f);
         dead = true;
         for (int i = 0; i < visIndex; i++)
         {
             if (i < snake.Count)
             {
                 snake[i].t.GetComponent <MeshRenderer>().material.color = Color.red;
             }
         }
     }
 }
Example #28
0
        public virtual void Move(float rightSpeed, bool hold = true)
        {
            Velocity  = new Vector2(rightSpeed, Velocity.y);
            Direction = (int)rightSpeed < 0 ? SpriteDirection.Left : (int)rightSpeed > 0 ? SpriteDirection.Right : Direction;
            // 着地音
            if ((IsCeiling() && !prevIsCeiling) || (IsGrounded() && !prevIsGrounded))
            {
                Sfx.Play(LandSfxId);
            }

            if (IsJumping && hold)
            {
                Velocity -= new Vector2(0, GravityScale * 0.05f);
            }

            if (IsCeiling() && Velocity.y > 0)
            {
                Velocity = new Vector2(Velocity.x, charaCeilingBouness);
            }
        }
Example #29
0
    /// <summary>
    /// ジャンプした時
    /// </summary>
    public virtual void Jump()
    {
        if (IsGrounded())
        {
            var nowVec = rigid.velocity;
            rigid.velocity = new Vector3(nowVec.x, charaJumpScale);
            IsJumping      = true;
            Sfx.Play(JumpSfxId);
        }

        /*else if (CanKickLeft())
         * {
         *      rigid
         * }
         * else if (CanKickRight())
         * {
         *      rigid.AddForce((Vector2.left + Vector2.up) * 3000);
         * }*/
        //TODO: プレイヤーの左右移動に加速度を取り入れ、外部からの圧力を無視しないようにする
    }
Example #30
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (IsAmbushed)
            {
                return;
            }

            input.Update();

            if (input.UpJustPressed() && Ground != null && ForceApplied >= 0)
            {
                Sfx.Play("pulo");
                Ground       = null;
                ForceApplied = jumpForce * -Scale;
            }

            if (!canTakeAir)
            {
                takeAirElapsedTime += gameTime.ElapsedGameTime.Milliseconds;

                if (HasTookAir && takeAirElapsedTime >= takeAirTime)
                {
                    HasTookAir = false;
                    (Sprite as AnimatedSprite).Change("Run");
                    (Sprite as AnimatedSprite).JumpToFrame(2);
                }

                if (takeAirElapsedTime >= takeAirCooldown)
                {
                    takeAirElapsedTime = 0;
                    canTakeAir         = true;
                }
            }

            if (input.SpaceJustPressed() && canTakeAir)
            {
                TakeAir();
            }
        }