상속: MonoBehaviour
예제 #1
0
    //To put it simple: IFlowObject is the basic type of anything the FlowPlayer can encounter while traversing..
    // That means every node, every pin and every connection is also an IFlowObject.If for some reason the passed
    // aObject is null, we have encountered a Dead End.
    protected override void DoOnFlowPlayerPaused(IFlowObject aObject)
    {
        // Debug.Log("**********************************************************************DoOnFlowPlayerPaused()");
        //Debug.Log("OnFlowPlayerPaused() IFlowObject Type: " + aObject.GetType() + ", with TechnicalName: " + ((ArticyObject)aObject).TechnicalName);
        StaticStuff.FlowDebug("**********************************************************************DoOnFlowPlayerPaused()");
        StaticStuff.FlowDebug("OnFlowPlayerPaused() IFlowObject Type: " + aObject.GetType() + ", with TechnicalName: " + ((ArticyObject)aObject).TechnicalName);
        CurPauseObject = aObject;
        // Note...a Dialogue Fragment is NOT a Flow Fragment
        var flowFragType = aObject as IObjectWithFeatureFlow_Fragment_Type;

        if (flowFragType != null)
        {
            Flow_Fragment_Type type     = flowFragType.GetFeatureFlow_Fragment_Type().Flow_Fragment_Type;
            FlowFragment       flowFrag = aObject as FlowFragment;
            //Debug.Log("Fragment name: " + flowFrag.DisplayName + ", has text: " + flowFrag.Text);
            //Debug.Log("enum val: " + type);
            StaticStuff.FlowDebug("Fragment name: " + flowFrag.DisplayName + ", has text: " + flowFrag.Text);
            StaticStuff.FlowDebug("enum val: " + type);
        }
        var dialogueFrag = aObject as Dialogue_Fragment;

        if (dialogueFrag != null)
        {
            //Debug.Log("We have a dialogue fragment...so DO SOMETHING");
            StaticStuff.FlowDebug("We have a dialogue fragment...so don't do anything since branch update will set up the dialogue fragment stuff there");
            // monote - "Ship.DoOnFlowPlayerPaused() about to show dialogue fragment"
            //Debug.LogWarning("We're changing the dialogue setup from Pause to BranchesUpdated because we can have more than 1");
            // base.ShowDialogueFragment(dialogueFrag);
        }
        //Debug.Log("**********DoOnFlowPlayerPaused() END");
        StaticStuff.FlowDebug("**********DoOnFlowPlayerPaused() END");
    }
예제 #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.name.Contains("Clockium"))
        {
            Destroy(collision.gameObject);

            StaticStuff.AddKarma(10);

            hasClockium       = true;
            speech.voiceLines = new List <string> {
                "Heavens, that's a huge hunk of clockium!", "I'm set for a lifetime!", "In the not-so-distant future, everyone in the region will have a watch.", "You're an angel."
            };
            if (!sick)
            {
                speech.fallBackLine = "I love making watches.";
            }
            else
            {
                speech.fallBackLine = "Must. Keep. Working...";
            }

            ResetSpeech();
        }

        if (!deathRevealed && !isAlive && Vector2.Distance(player.transform.position, transform.position) < 10)
        {
            StaticStuff.RemoveKarma(10);
            deathRevealed = true;
        }
    }
    protected void PrintBranchInfo(Branch b, string src = "")
    {
        string s = GetBranchInfo(b, src);

        //Debug.Log(s);
        StaticStuff.FlowDebug(s);
    }
예제 #4
0
 void PlaySound(AudioClip[] clip)
 {
     src.volume = 0.5f;
     src.clip   = clip[Random.Range(0, clip.Length - 1)];
     src.Play();
     StartCoroutine(StaticStuff.StartFade(src, src.clip.length, 0));
 }
    // Start is called before the first frame update
    public virtual void Start()
    {
        PlayerCharacter PC = ArticyDatabase.GetObject <PlayerCharacter>("Player_Character_Entity_Tech_Name");

        //Debug.Log("Our player name is: " + PC.Template.Basic_Character_Attributes.NPC_Feature_Name);
        StaticStuff.FlowDebug("Our player name is: " + PC.Template.Basic_Character_Attributes.NPC_Feature_Name);

        FlowPlayer = GetComponent <ArticyFlowPlayer>();
        Slot_Container sc = ArticyDatabase.GetObject <Slot_Container>("Start_On_Object");

        if (sc.Template.Slot_Feature.Slot_Feature_Slot != null)
        {
            //Debug.Log("CaptainsChairSceneRoot.Start() setting StartOn: " + sc.Template.Slot_Feature.Slot_Feature_Slot.name);
            StaticStuff.FlowDebug("CaptainsChairSceneRoot.Start() setting StartOn: " + sc.Template.Slot_Feature.Slot_Feature_Slot.name);
            SetFlowPlayerStartOn(sc.Template.Slot_Feature.Slot_Feature_Slot);
        }
        else
        {
            //Debug.Log("CaptainsChairSceneRoot.Start() no StartOn");
            StaticStuff.FlowDebug("CaptainsChairSceneRoot.Start() no StartOn");
        }

        if (DialogueUI != null)
        {
            DialogueUI.gameObject.SetActive(false);
        }
        //FlowPlayer.StartOn = sc.Template.Slot_Feature.Slot_Feature_Slot;
    }
    private void OnTriggerEnter(Collider other)
    {
        StaticStuff.FlowDebug(this.name + " OnTriggerEnter() other: " + other.name);

        ArticyReference colliderArtRef = other.gameObject.GetComponent <ArticyReference>();

        if (colliderArtRef == null)
        {
            //Debug.LogWarning("null ArticyReference on the thing we collided with.");
            StaticStuff.FlowDebugWarning("null ArticyReference on the thing we collided with.");
        }
        else
        {
            //Debug.Log("we connected with something that has an ArticyRef.  Now lets see if it's an NPC.");
            StaticStuff.FlowDebug("we connected with something that has an ArticyRef.  Now lets see what it is.");
            Dialogue dialogue = colliderArtRef.reference.GetObject() as Dialogue;
            if (dialogue != null)
            {
                StaticStuff.FlowDebug("we have a dialogue, so set the FlowPlayer to start on it");
                SceneRoot.SetFlowPlayerStartOn(dialogue);
                NavMeshAgent.SetDestination(this.transform.position);
            }
            else
            {
                StaticStuff.FlowDebugWarning("not sure what to do with this type yet: " + colliderArtRef.reference.GetObject().GetType());
            }
        }
    }
예제 #7
0
 protected virtual void Update()
 {
     if (!isAlive && !deathRevealed && Vector2.Distance(player.transform.position, transform.position) < 8)
     {
         StaticStuff.RemoveKarma(10);
         deathRevealed = true;
     }
 }
예제 #8
0
 public void Damage(float amt)
 {
     health -= amt;
     StaticStuff.OnHealthChange();
     if (health <= 0)
     {
         Kill();
     }
 }
예제 #9
0
 public void MudmanDestroyed()
 {
     StaticStuff.RemoveKarma(10);
     GetComponent <SpeechController>().fallBackLine = "*quiet sobbing*";
     speech.Clear();
     speech.voiceLines.Add("My... My mudman!");
     ResetSpeech();
     GetComponent <Animator>().SetTrigger("Sad");
     Destroy(this);
 }
예제 #10
0
 protected override void Update()
 {
     base.Update();
     if (isAlive && isStuck && rock == null)
     {
         anim.SetTrigger("StandUp");
         speech.fallBackLine = "I'll always be in your debt!";
         speech.voiceLines   = new List <string> {
             "Thank you kind sir!"
         };
         ResetSpeech();
         StaticStuff.AddKarma(10);
         isStuck = false;
     }
 }
예제 #11
0
    // Update is called once per frame
    protected override void Update()
    {
        base.Update();

        if (!rocksGone && rock1 == null && rock2 == null && rock3 == null)
        {
            rocksGone = true;
            StaticStuff.AddKarma(10);
            speech.voiceLines = new List <string> {
                "You krumped dem rocks? That's roight bloody sweet uv ya!", "Oi'll get roight ta plantin'!"
            };
            speech.fallBackLine = "Stop buggerin' me! Oi'm right 'boutta get ta work, oi am!";
            ResetSpeech();
        }
    }
예제 #12
0
 private void loginB_Click(object sender, RoutedEventArgs e)
 {
     if (userIDTB.Text.Length == 0 || passwordPB.Password.Length == 0)
     {
         MessageBox.Show("用户ID和密码不能为空");
         return;
     }
     loginB.IsEnabled = false;
     loginB.Content   = "登录中...";
     if (!(connector.connect() && connector.Login(userIDTB.Text, StaticStuff.GetMD5(passwordPB.Password))))
     {
         MessageBox.Show(this, "登录失败,无法连接服务器!");
         loginB.IsEnabled = true;
         loginB.Content   = "登录";
     }
 }
예제 #13
0
 public void DialogueButtonCallback(int buttonIndex)
 {
     StaticStuff.FlowDebug("DialogueButtonCallback() buttonIndex: " + buttonIndex);
     NextBranch = CurBranches[buttonIndex];
     base.PrintBranchInfo(CurBranches[buttonIndex], "DialogueButtonCallback");
     if (CurBranches[buttonIndex].Target.GetType().Equals(typeof(Dialogue_Fragment)) == false)
     {
         //Debug.Log("we're done with the current dialogue tree, so shut off the UI and let the flow handle itself");
         StaticStuff.FlowDebug("Chosen branch isn't a dialogue fragment, so for now assume we're done talking and shut off the UI");
         base.ShutOffDialogueUI();
     }
     else
     {
         //Debug.LogWarning("Need to account for a flow fragment off of a dialogue UI button press");
         StaticStuff.FlowDebug("Chosen branch is a dialogue fragment, so just let the engine handle the next phase.");
     }
 }
    protected void GoToMiniGame(Branch branch)
    {
        var miniGameFrag = branch.Target as IObjectWithFeatureMini_Game_Name;

        if (miniGameFrag != null)
        {
            //Debug.Log("go to this mini game NOW: " + miniGameFrag.GetFeatureMini_Game__Name().Mini_Game_Name);
            StaticStuff.FlowDebug("go to this mini game NOW: " + miniGameFrag.GetFeatureMini_Game_Name().Mini_Game_Name);
            // FlowPlayer.StartOn = branch.Target as IArticyObject;
            Slot_Container slotContainer = ArticyDatabase.GetObject <Slot_Container>("Start_On_Object");
            slotContainer.Template.Slot_Feature.Slot_Feature_Slot = (ArticyObject)branch.Target;
            SceneManager.LoadScene(miniGameFrag.GetFeatureMini_Game_Name().Mini_Game_Name);
        }
        else
        {
            //Debug.LogError("ERROR: trying to go to a mini game with no name");
            StaticStuff.FlowDebug("ERROR: trying to go to a mini game with no name");
        }
    }
예제 #15
0
        public Decimal CalculateBlackScholesPrice(TradingAccount tradingAccount, Decimal underlyingPrice)
        {
            Double S0    = (Double)underlyingPrice;
            Double X     = (Double)this.Strike;
            Double sigma = (Double)this.ImpliedVolatility;
            Double r     = (Double)tradingAccount.RiskFreeInterestRate;
            Double t     = ((Double)this.ExpiryDays) / 365.0;

            Double d1 = (Math.Log(S0 / X) + (t * (r + (Math.Pow(sigma, 2) / 2)))) / (sigma * Math.Sqrt(t));
            Double d2 = d1 - (sigma * Math.Sqrt(t));

            if (this.OptionType == OptionTypes.Call)
            {
                return((Decimal)((S0 * StaticStuff.N(d1)) - (X * Math.Pow(Math.E, -(r * t)) * StaticStuff.N(d2))));
            }
            else
            {
                return((Decimal)((X * Math.Pow(Math.E, -(r * t)) * StaticStuff.N(-d2)) - (S0 * StaticStuff.N(-d1))));
            }
        }
    protected void ShowDialogueFragment(Dialogue_Fragment dialogueFrag, List <Branch> dialogueOptions)
    {
        StaticStuff.FlowDebug("going to set up a dialogue fragment with speaker: " + dialogueFrag.Speaker + " with text: " + dialogueFrag.Text);
        StaticStuff.FlowDebug("this dialogue fragment has: " + dialogueOptions.Count + " options");

        DialogueUI.gameObject.SetActive(true);
        SetSpeakerImage(dialogueFrag.Speaker);
        SpeakerText.text = dialogueFrag.Text;

        foreach (GameObject go in DialogueOptions)
        {
            go.SetActive(false);
        }
        for (int i = 0; i < dialogueOptions.Count; i++)
        {
            DialogueOptions[i].SetActive(true);
            Dialogue_Fragment df = dialogueOptions[i].Target as Dialogue_Fragment;
            if (df != null)
            {
                DialogueOptions[i].GetComponentInChildren <Text>().text = df.MenuText;
            }
            else
            {
                string buttonText = dialogueFrag.Template.Dialogue_Fragment_Default_Button_Text.Default_Button_Text;
                StaticStuff.FlowDebug("ok we are not going to a dialogue fragment, so get the button text by the template: " + buttonText);
                if (buttonText.Equals("") == false)
                {
                    DialogueOptions[i].GetComponentInChildren <Text>().text = buttonText;
                }
                else
                {
                    string val = ArticyDatabase.DefaultGlobalVariables.GetVariableByString <string>("Misc_Globals.defaultDialogueFragmentButtonText");
                    DialogueOptions[i].GetComponentInChildren <Text>().text = val;
                }
            }
        }

        PlayerObject.ToggleMovementBlocked(true);
    }
예제 #17
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.name.Contains("Chowbeet") && hungry)
        {
            Destroy(collision.gameObject);

            StaticStuff.AddKarma(10);

            hungry            = false;
            speech.voiceLines = new List <string> {
                "Wowie, thanks! That is one thick beet.", "I'm chowing down on this yummy snack this instant."
            };
            speech.fallBackLine = "I don't know if I'll ever be hungry again!";

            ResetSpeech();
        }

        if (!deathRevealed && !isAlive && Vector2.Distance(player.transform.position, transform.position) < 10)
        {
            StaticStuff.RemoveKarma(10);
            deathRevealed = true;
        }
    }
예제 #18
0
 private void signUpB_Click(object sender, RoutedEventArgs e)
 {
     if (nickNameTB.Text.Length == 0 || passwordPB.Password.Length == 0)
     {
         MessageBox.Show(this, "昵称或密码不可为空!");
         return;
     }
     char[] c = { ';', '\0' };
     if (nickNameTB.Text.IndexOfAny(c) >= 0 || passwordPB.Password.IndexOfAny(c) >= 0)
     {
         MessageBox.Show(this, "昵称或密码中不可含有';'和'\0'!");
         return;
     }
     if (nickNameTB.Text.Length > 20 || passwordPB.Password.Length > 20)
     {
         MessageBox.Show(this, "昵称或密码不得超过20字符长!");
         return;
     }
     NickName     = nickNameTB.Text;
     Password     = StaticStuff.GetMD5(passwordPB.Password);
     DialogResult = true;
     Close();
 }
예제 #19
0
    // Update is called once per frame
    override protected void Update()
    {
        base.Update();
        if (canonTriggered && !canonBoom)
        {
            canonTimer -= Time.deltaTime;
            if (canonTimer < 0)
            {
                canonAudio.clip = canonFire;
                canonAudio.Play();
                canonBoom = true;
                Instantiate(smokeEffect, canon.transform.position + new Vector3(-2.4f, 0.1f), Quaternion.identity);
                canon.GetComponent <Animator>().SetTrigger("Reset");


                Vector3 playerPos = GameObject.Find("Player").transform.position;
                //Ah shit he dead
                if (transform.position.x < playerPos.x && playerPos.x < canon.transform.position.x && Mathf.Abs(playerPos.y - transform.position.y) < 4)
                {
                    GameObject.Find("Player").GetComponent <PlayerController>().Die();
                    speech.voiceLines = new List <string> {
                        "Good Heavens!"
                    };
                    ResetSpeech();
                    StaticStuff.AddKarma(10);
                }
                //Ah shit me dead
                else
                {
                    anim.SetTrigger("Die");
                    Instantiate(smokeEffect, transform.position, Quaternion.Euler(1, 0, 0));
                    Die(true);
                }
            }
        }
    }
 public void SetFlowPlayerStartOn(ArticyObject articyObject)
 {
     //Debug.Log("SetFlowPlayerStartOn(): type: " + articyObject.GetType() + ", name: " + articyObject.name);
     StaticStuff.FlowDebug("SetFlowPlayerStartOn(): type: " + articyObject.GetType() + ", name: " + articyObject.name);
     FlowPlayer.StartOn = articyObject;
 }
예제 #21
0
    private void Update()
    {
        float move = Input.GetAxisRaw("Horizontal") * Time.deltaTime * moveSpeed;

        cc.Move(Vector3.right * move);

        if (transform.position.x > moveRange)
        {
            transform.position = new Vector3(moveRange, transform.position.y, transform.position.z);
        }
        else if (transform.position.x < -moveRange)
        {
            transform.position = new Vector3(-moveRange, transform.position.y, transform.position.z);
        }

        if (transform.position.y != yPos)
        {
            transform.position = new Vector3(transform.position.x, yPos, transform.position.z);
        }


        if (regenTimer > 0)
        {
            regenTimer -= Time.deltaTime;
        }

        if (regenTimer <= 0)
        {
            regenTimer = hpRegenWait;
            if (health <= maxHealth - 1.0f)
            {
                Damage(-1.0f);
                StaticStuff.score += 1;
                StaticStuff.OnScoreChange();
            }
        }



        if (gunHeat > 0)
        {
            gunHeat -= Time.deltaTime;
        }

        if (gunHeat <= 0)
        {
            gunHeat = gunCooldown;

            GameObject o = bulletPool.GetObject();
            o.transform.position = transform.position;
            o.transform.rotation = transform.rotation;
            o.SetActive(true);
            o.GetComponent <PlayerBullet>().Shoot();

            o = bulletPool.GetObject();
            o.transform.position    = transform.position;
            o.transform.eulerAngles = transform.eulerAngles + new Vector3(0, sideBulletAngle, 0);
            o.SetActive(true);
            o.GetComponent <PlayerBullet>().Shoot();

            o = bulletPool.GetObject();
            o.transform.position    = transform.position;
            o.transform.eulerAngles = transform.eulerAngles + new Vector3(0, -sideBulletAngle, 0);
            o.SetActive(true);
            o.GetComponent <PlayerBullet>().Shoot();
        }
    }
예제 #22
0
 public void Kill()
 {
     StaticStuff.score += scoreOnKill;
     StaticStuff.OnScoreChange();
     Destroy(gameObject);
 }
예제 #23
0
    // iFlowObject vs Branch
    //  Branch.Target is an iFlowObjects

    protected override void DoOnBranchesUpdated(IList <Branch> aBranches)
    {
        //Debug.Log("**********DoOnBranchesUpdated()");
        //Debug.Log("Num branches: " + aBranches.Count);
        StaticStuff.FlowDebug("**********DoOnBranchesUpdated()");
        StaticStuff.FlowDebug("Num branches: " + aBranches.Count);

        List <Branch> validBranches = new List <Branch>();

        CurBranches.Clear();
        string s = "";

        foreach (Branch b in aBranches)
        {
            base.PrintBranchInfo(b, "branch loop");
            Dialogue_Fragment d = b.Target as Dialogue_Fragment;
            if (d != null)
            {
                s += "Branch " + b.BranchId + ": ";
                s += d.InputPins[0].Text.RawScript + "\n";
            }
            //if (s != "") DebugText.text = s;
            CurBranches.Add(b);
            if (b.IsValid == true)
            {
                validBranches.Add(b);
            }
        }

        if (aBranches.Count == 1 && aBranches[0].IsValid && aBranches[0].Target.GetType().Equals(typeof(Hub)))
        {
            StaticStuff.FlowDebug("only one valid branch and it's a hub called: " + aBranches[0].DefaultDescription + " so Play() it");
            NextBranch = aBranches[0];
            base.PrintBranchInfo(NextBranch, "move to hub");
            //inventorySystem.RemoveItem(heldItem);
            //inventorySystem.RemoveItem(thisRepresentedItem);
        }
        else
        {
            if (validBranches.Count == 1 && CurPauseObject.GetType().Equals(typeof(Hub)))
            {
                s  = "1 valid branch on a hub pause object...check what it is: ";
                s += base.ReturnBranchInfo(validBranches[0], "checking 1 branch on hub");
                StaticStuff.FlowDebug(s);
                if (validBranches[0].Target.GetType().Equals(typeof(OutputPin)))
                {
                    StaticStuff.FlowDebug("only valid output is an OutputPin...which means that we're not linked to any other flow fragments so just sit tight and wait for something" +
                                          "like the player colliding with an NPC or something else to trigger the next StartOn");
                }
                else
                {
                    StaticStuff.FlowDebug("only valid output is something else that an OutputPin...so ROCK IT via Play(NextBranch)");
                    NextBranch = validBranches[0];
                }
            }
            else
            {
                StaticStuff.FlowDebug("--------------------------NOT in a situation where we have 1 valid Hub branch, so find out what to do.");
                if (CurPauseObject.GetType().Equals(typeof(Dialogue_Fragment)))
                {
                    StaticStuff.FlowDebug("We're on a dialogue fragment, so set up the dialogue via the CaptainsChairSceneRoot");
                    base.ShowDialogueFragment(CurPauseObject as Dialogue_Fragment, validBranches);
                }
                else
                {
                    StaticStuff.FlowDebug("on something other than a dialogue fragment, so find out what to do");
                    if (validBranches.Count == 1 && CurPauseObject.GetType().Equals(typeof(Jump)) && validBranches[0].Target.GetType().Equals(typeof(MiniGameFragment)))
                    {
                        StaticStuff.FlowDebug("we have 1 valid branch that's a Jump to a MiniGame so go to that mini game");
                        base.GoToMiniGame(validBranches[0]);
                    }
                    else
                    {
                        StaticStuff.FlowDebugWarning("not a 1 valid brach that's a Jump to a MiniGame so figure out what to do");
                    }
                }
            }
        }
        StaticStuff.FlowDebug("************************************************************DoOnBranchesUpdated() END");
    }
예제 #24
0
    // Update is called once per frame
    void Update()
    {
        grounded = Physics2D.OverlapArea((Vector2)transform.position + new Vector2(-0.1f, 0), (Vector2)transform.position + new Vector2(0.1f, -0.1f), StaticStuff.SolidLayers);
        anim.SetBool("Grounded", grounded);

        if (isAlive)
        {
            switch (state)
            {
            case State.Moving:
                float xMove = Input.GetAxis("Horizontal");
                anim.SetFloat("Abs X Move", Mathf.Abs(xMove));

                rb.velocity = new Vector2(xMove * movementSpeed, rb.velocity.y);

                if (xMove != 0)
                {
                    transform.localScale = new Vector2((xMove > 0) ? 1 : -1, 1);

                    if (stepTimer <= 0 && grounded)
                    {
                        PlaySound(step);
                        stepTimer = 0.5f;
                    }
                }
                stepTimer -= Time.deltaTime;

                textHolder.transform.localScale = transform.localScale;

                if (Input.GetButtonDown("Jump") && grounded)
                {
                    rb.velocity = new Vector2(rb.velocity.x, jumpForce);
                }

                if (Input.GetButtonDown("Fire1"))
                {
                    state = State.Attacking;
                    anim.Play("playerAttack");
                    timeAttacking = 0;
                    hasAttacked   = false;
                }

                if (Input.GetButtonDown("PickUp"))
                {
                    PickUp();
                }

                if (Input.GetKeyDown(KeyCode.G))
                {
                    state = State.Grooving;
                    anim.Play("playerGroove");
                }
                break;

            case State.Attacking:
                //Attack logic
                timeAttacking += Time.deltaTime;

                rb.velocity = new Vector2(rb.velocity.x / Mathf.Pow(10, Time.deltaTime), rb.velocity.y);

                if (timeAttacking >= attackResolutionTime)
                {
                    if (!hasAttacked)
                    {
                        Collider2D[]    r  = new Collider2D[5];
                        ContactFilter2D cf = new ContactFilter2D();
                        cf.layerMask    = StaticStuff.Destructibles;
                        cf.useLayerMask = true;
                        Physics2D.OverlapCircle(new Vector2(transform.position.x + attackOffset.x * transform.localScale.x, transform.position.y + attackOffset.y), 0.25f, cf, r);
                        for (int i = 0; i < r.Length; i++)
                        {
                            if (r[i] != null && r[i].gameObject != gameObject)
                            {
                                if (r[i].CompareTag("Destructible"))
                                {
                                    Destroy(r[i].gameObject);
                                    PlaySound(hit);
                                }

                                //EXCEPTIONS
                                try {
                                    if (r[i].name == "Mudman")
                                    {
                                        PlaySound(hit);
                                        BoyController boy             = GameObject.Find("Boy").GetComponent <BoyController>();
                                        Sprite        destroyedMudman = boy.destroyedMudman;
                                        r[i].GetComponent <SpriteRenderer>().sprite = destroyedMudman;
                                        boy.MudmanDestroyed();
                                    }
                                } catch {
                                    //Nothing
                                }
                            }


                            hasAttacked = true;
                        }
                    }

                    if (timeAttacking >= attackRecoveryTime)
                    {
                        state = State.Moving;
                    }
                }
                break;

            case State.Staggered:
                timeStaggered += Time.deltaTime;

                rb.velocity = new Vector2(rb.velocity.x / Mathf.Pow(10, Time.deltaTime), rb.velocity.y);

                if (timeStaggered > 0.4f)
                {
                    state = State.Moving;
                }
                break;

            case State.Grooving:
                rb.velocity = new Vector2(rb.velocity.x / Mathf.Pow(10, Time.deltaTime), rb.velocity.y);

                if (Input.GetKeyUp(KeyCode.G))
                {
                    state = State.Moving;
                    anim.Play("playerIdle");
                }
                break;

            case State.Sleeping:
                rb.velocity = new Vector2(rb.velocity.x / Mathf.Pow(10, Time.deltaTime), rb.velocity.y);
                break;

            default:
                break;
            }

            HandleSpeech();

            if (nearbyItems.Count > 0)
            {
                nearbyItems.OrderBy(item => (item.transform.position - transform.position).magnitude);
                nearestItem = nearbyItems[0];
            }
            else
            {
                nearestItem = null;
            }

            float pttt = timeToLive;
            timeToLive -= Time.deltaTime;

            if (pttt > 50 && timeToLive < 50)
            {
                voiceLines.Add("I feel a strange, unnerving sensation.");
            }

            if (pttt > 5 && timeToLive < 5)
            {
                voiceLines.Add("Ow! It hurts at my very core!");
            }

            if (timeToLive <= 0)
            {
                Debug.Log("Time ran out, heart attack");
                Die();
            }
        }
        else
        {
            timeDead += Time.deltaTime;

            rb.velocity = new Vector2(rb.velocity.x / Mathf.Pow(10, Time.deltaTime), rb.velocity.y);

            if (timeDead >= timeDeadMax)
            {
                //Reincarnate
                isAlive            = true;
                transform.position = reincarnationPoint;
                timeToLive         = startTimeToLive;
                StaticStuff.EndLifeCycle();
                anim.Play("playerIdle");
                state = State.Moving;
            }
        }
    }
예제 #25
0
 private void Awake()
 {
     i             = this;
     playerOutside = Helper.ToLayer(playerOutsideMask);
     playerInside  = Helper.ToLayer(playerInsideMask);
 }