예제 #1
0
    void LateUpdate()
    {
        // check left bound.
        if (transform.position.x - (spriteWidth / 2 - leftOffset) < leftBound)
        {
            transform.SetPositionX(leftBound + (spriteWidth / 2 - leftOffset));
        }

        // check right bound.
        if (transform.position.x + (spriteWidth / 2 - rightOffset) > rightBound)
        {
            transform.SetPositionX(rightBound - (spriteWidth / 2 - rightOffset));
        }

        // check upper bound.
        if (transform.position.y + (spriteHeight - upperOffset) > upperBound)
        {
            transform.SetPositionY(upperBound - (spriteHeight - upperOffset));
        }

        // check lower bound.
        if (transform.position.y - lowerOffset < lowerBound)
        {
            transform.SetPositionY(lowerBound - lowerOffset);
            EventKit.Broadcast <int, Weapon.WeaponType>("player dead", -1, Weapon.WeaponType.OutOfBounds);
        }
    }
    public void TakesHit(Hit hit)
    {
        player.HP -= (hit.weapon.damage * diffDamageModifier);

        //params for ShakeCamera = duration, strength, vibrato, randomness
        EventKit.Broadcast("shake camera", .5f, .3f, 20, 5f);
        EventKit.Broadcast("reduce hp", player.HP);

        if (hit.horizontalSide == Side.Right)
        {
            gameObject.SendEventDown("RepulseToLeft", 5.0F);
        }
        else
        {
            gameObject.SendEventDown("RepulseToRight", 5.0F);
        }

        if (player.HP > 0)
        {
            fadeWhenHit.Restart();
        }
        else
        {
            OnPlayerDead(hit);
            EventKit.Broadcast("player dead", hit);
        }
    }
    void Update()
    {
        float h;

        h = playerControls.GetAxisRaw("Move Horizontal");

        if (h > 0)
        {
            creature.MoveRight();
        }

        if (h < 0)
        {
            creature.MoveLeft();
        }

        if (playerControls.GetButtonDown("Jump"))
        {
            creature.Jump();
        }

        if (playerControls.GetButtonDown("Attack"))
        {
            creature.Attack();
        }

        if (playerControls.GetButtonDown("Next Weapon"))
        {
            EventKit.Broadcast <int>("switch weapon", RIGHT);
        }
    }
예제 #4
0
    public void TakesHit(Hit hit)
    {
        player.HP -= (int)(hit.weapon.damage * diffDamageModifier);

        //params for ShakeCamera = duration, strength, vibrato, randomness
        EventKit.Broadcast <float, float, int, float>("shake camera", .5f, .3f, 20, 5f);
        EventKit.Broadcast <int>("reduce hp", player.HP);

        if (hit.hitFrom == RIGHT)
        {
            BroadcastMessage("RepulseToLeft", 5.0F);
        }
        else
        {
            BroadcastMessage("RepulseToRight", 5.0F);
        }

        if (player.HP > 0)
        {
            MFX.FadeToColorAndBack(spriteRenderer, MCLR.bloodRed, 0f, .2f);
        }
        else
        {
            EventKit.Broadcast <int, Weapon.WeaponType>("player dead", hit.hitFrom, hit.weaponType);
        }
    }
    public void TakesProjectileHit(Weapon incomingWeapon, Collider2D coll)
    {
        if (!dead)
        {
            var hitSide = M.HorizontalSideHit(gameObject, coll);

            hp -= (incomingWeapon.damage);

            if (hitSide == RIGHT && !blockedLeft)
            {
            }
            else if (hitSide == LEFT && !blockedRight)
            {
            }
            else
            {
                rigidbody2D.velocity = Vector2.zero;
            }

            if (hp <= 0)
            {
                EventKit.Broadcast("prize collected", worth);
                KillSelf(hitSide, PROJECTILE);
            }
        }
    }
예제 #6
0
파일: GameNote.cs 프로젝트: yuki4080/Cytoid
    public virtual void Clear(NoteGrade grade)
    {
        if (IsCleared || grade == NoteGrade.Undetermined)
        {
            return;
        }

        IsCleared = true;
        Game.OnClear(this);
        View.OnClear(grade);

        if (!(Game.Instance is StoryboardGame))
        {
            StartCoroutine(DestroyLater());
        }

        if (TimeUntilEnd > -5) // Prevent storyboard seeking
        {
            EventKit.Broadcast("note clear", this);
        }

        // Hit sound
        if (grade != NoteGrade.Miss && (!(this is HoldNote) || !PlayerPrefsExt.GetBool("early hit sounds")))
        {
            PlayHitSound();
        }

        // gameObject.GetComponent<SpriteRenderer> ().material.SetFloat("_HRate", 1.0f);
        // Animation speed = 1.0f;
    }
예제 #7
0
 void OnPlayerDead(int hitFrom, Weapon.WeaponType weaponType)
 {
     gameData.CurrentScore = gameData.LastSavedScore;
     gameData.Lives       -= 1;
     EventKit.Broadcast <bool>("fade hud", true);
     EventKit.Broadcast <int>("load level", gameData.CurrentLevel);
 }
    void PlatformSpecificUpdate()
    {
        float h;

        h = Input.GetAxisRaw("Horizontal");

        if (h > 0)
        {
            creature.MoveRight();
        }

        if (h < 0)
        {
            creature.MoveLeft();
        }

        if (Input.GetButtonDown("Jump"))
        {
            creature.Jump();
        }

        if (Input.GetButtonDown("Attack"))
        {
            creature.Attack();
        }

        if (Input.GetButtonDown("Switch"))
        {
            EventKit.Broadcast("switch weapon", Side.Right);
        }
    }
 void OnPlayerDead(Hit incomingHit)
 {
     gameData.CurrentScore = gameData.LastSavedScore;
     gameData.Lives       -= 1;
     EventKit.Broadcast("fade hud", true);
     EventKit.Broadcast("load level", gameData.CurrentLevel);
 }
 void OnLevelCompleted(bool status)
 {
     gameData.LastSavedScore = gameData.CurrentScore;
     gameData.CurrentLevel   = gameData.CurrentLevel;
     EventKit.Broadcast("fade hud", true);
     EventKit.Broadcast("load level", gameData.CurrentLevel);
 }
예제 #11
0
    public void SwitchRankedMode()
    {
        if (isLoggingIn)
        {
            Popup.Make(this, "Now signing in, please wait...");
            return;
        }

        if (OnlinePlayer.Authenticated)
        {
            var ranked = PlayerPrefsExt.GetBool("ranked", false);
            ranked = !ranked;
            PlayerPrefsExt.SetBool("ranked", ranked);
            rankStatusText.text = ranked ? "On" : "Off";
            UpdateBestText();
            if (ranked && !PlayerPrefsExt.GetBool("dont_show_what_is_ranked_mode_again", false))
            {
                UIManager.ShowUiElement("WhatIsRankedModeBackground", "MusicSelection");
                UIManager.ShowUiElement("WhatIsRankedModeRoot", "MusicSelection");
            }

            if (ranked)
            {
                EventKit.Broadcast("reload rankings");
            }
        }
        else
        {
            UIManager.ShowUiElement("LoginRoot", "MusicSelection");
            UIManager.ShowUiElement("LoginBackground", "MusicSelection");
        }
    }
예제 #12
0
    public void OnProfilePressed()
    {
        if (isLoggingIn)
        {
            Popup.Make(this, "Now signing in, please wait...");
            return;
        }

        if (OnlinePlayer.Authenticated)
        {
            if (UIManager.GetUiElements("ProfileRoot", "MusicSelection")[0].isVisible)
            {
                UIManager.HideUiElement("ProfileRoot", "MusicSelection");
                UIManager.HideUiElement("ProfileBackground", "MusicSelection");
            }
            else
            {
                UIManager.ShowUiElement("ProfileRoot", "MusicSelection");
                UIManager.ShowUiElement("ProfileBackground", "MusicSelection");
                EventKit.Broadcast("reload player rankings");
            }
        }
        else
        {
            UIManager.ShowUiElement("LoginRoot", "MusicSelection");
            UIManager.ShowUiElement("LoginBackground", "MusicSelection");
        }
    }
예제 #13
0
    void TakesProjectileHit(Weapon playerWeapon, Collider2D coll, int hitFrom)
    {
        if (!dead)
        {
            hp -= (int)(playerWeapon.damage);

            // bounceback from projectile
            if (hitFrom == RIGHT && !blockedLeft)
            {
                // rigidbody2D.AddForce(new Vector3(-100, 0, 0));
                MFX.RepulseToLeftRandomly(transform, .3f, .8f, .2f);
            }
            else if (hitFrom == LEFT && !blockedRight)
            {
                // rigidbody2D.AddForce(new Vector3(100, 0, 0));
                MFX.RepulseToRightRandomly(transform, .3f, .8f, .2f);
            }
            else
            {
                rigidbody2D.velocity = Vector2.zero;
            }

            if (hp <= 0)
            {
                EventKit.Broadcast <int>("prize collected", worth);
                KillSelf(hitFrom, PROJECTILE);
            }
        }
    }
예제 #14
0
    void TakesMeleeHit(Weapon playerWeapon, Collider2D coll, int hitFrom)
    {
        if (!dead)
        {
            hp -= (int)(playerWeapon.damage);

            // bounceback from projectile
            if (hitFrom == RIGHT && !blockedLeft)
            {
                MFX.RepulseToLeftRandomly(transform, repulseMin, repulseMax, repulseTime);
            }
            else if (hitFrom == LEFT && !blockedRight)
            {
                MFX.RepulseToRightRandomly(transform, repulseMin, repulseMax, repulseTime);
            }
            else
            {
                rigidbody2D.velocity = Vector2.zero;
            }

            if (hp <= 0)
            {
                EventKit.Broadcast <int>("prize collected", worth);
                KillSelf(hitFrom, MELEE);
            }
        }
    }
예제 #15
0
    public override void InteractWith(GameObject character)
    {
        ClosePopup();

        var pack = Object.Instantiate(prefab, transform.position + ( Vector3 )genOffset, Quaternion.identity);

        EventKit.Broadcast(GlobalSymbol.EVT_ExpressPackageGenerated, pack);
    }
 void Init()
 {
     EventKit.Broadcast("init lvl", player.LVL);
     EventKit.Broadcast("init hp", player.HP);
     EventKit.Broadcast("init ac", player.AC);
     EventKit.Broadcast("init xp", player.XP);
     EventKit.Broadcast("init weapons", player.equippedWeapon, player.leftWeapon, player.rightWeapon);
 }
    void Start()
    {
        gameData = GameObject.Find(_DATA).GetComponent <GameData>();
        Assert.IsNotNull(gameData);

        EventKit.Broadcast("init score", gameData.CurrentScore);
        EventKit.Broadcast("set difficulty", NORMAL);
    }
예제 #18
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.gameObject.layer == PLAYER_DEFAULT_LAYER)
     {
         pickupWeapon.Restart();
         EventKit.Broadcast("prize collected", transform.parent.GetComponent <Weapon>().worth);
         EventKit.Broadcast("equip new weapon", transform.parent.gameObject);
     }
 }
예제 #19
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.gameObject.layer == PLAYER_COLLIDER)
     {
         MFX.PickupWeapon(gameObject);
         EventKit.Broadcast <int>("prize collected", transform.parent.GetComponent <Weapon>().worth);
         EventKit.Broadcast <GameObject>("equip new weapon", transform.parent.gameObject);
     }
 }
예제 #20
0
    void CheckForSizeChange()
    {
        if (Screen.width != currentScreenWidth || Screen.height != currentScreenHeight)
        {
            vertExtent  = Camera.main.GetComponent <Camera>().orthographicSize;
            horizExtent = vertExtent * Screen.width / Screen.height;

            EventKit.Broadcast <float, float>("screen size changed", vertExtent, horizExtent);
        }
    }
    void CheckForSizeChange()
    {
        if (Screen.width != currentScreenWidth || Screen.height != currentScreenHeight)
        {
            vertExtent  = camera.orthographicSize;
            horizExtent = vertExtent * Screen.width / Screen.height;

            EventKit.Broadcast("screen size changed");
        }
    }
예제 #22
0
    void OnTriggerExit2D(Collider2D coll)
    {
        layer = coll.gameObject.layer;

        coll.transform.parent = null;

        if (layer == PLAYER_COLLIDER && fastPlatform)
        {
            EventKit.Broadcast <bool>("player riding fast platform", false);
        }
    }
예제 #23
0
    public IEnumerator LoginCoroutine()
    {
        if (OnlinePlayer.Authenticated || !PlayerPrefs.HasKey(PreferenceKeys.LastUsername()) ||
            !PlayerPrefs.HasKey(PreferenceKeys.LastPassword()))
        {
            isLoggingIn = false;
            yield break;
        }

        // If not logged in previously
        yield return(OnlinePlayer.Authenticate());

        CloseLoginWindows();
        isLoggingIn = false;

        var authenticationResult = OnlinePlayer.LastAuthenticationResult;

        switch (authenticationResult.status)
        {
        case 0:
            Popup.Make(this, "Signed in.");
            rankStatusText.text = PlayerPrefsExt.GetBool("ranked") ? "On" : "Off";
            StartCoroutine(LoadAvatarCoroutine());
            if (PlayerPrefsExt.GetBool("ranked"))
            {
                EventKit.Broadcast("reload rankings");
            }
            BestScoreText.WillInvalidate = true;

            break;

        case -1:
            LoadedAvatar = true;
            Popup.Make(this, "Could not fetch player data.");
            break;

        case 1:     // User not exist
            LoadedAvatar = true;
            Popup.Make(this, authenticationResult.message);
            PlayerPrefs.DeleteKey(PreferenceKeys.LastUsername());
            PlayerPrefs.DeleteKey(PreferenceKeys.LastPassword());
            usernameInput.text = "";
            passwordInput.text = "";
            break;

        case 2:     // Incorrect password
            LoadedAvatar = true;
            Popup.Make(this, authenticationResult.message);
            PlayerPrefs.DeleteKey(PreferenceKeys.LastPassword());
            passwordInput.text = "";
            break;
        }
    }
예제 #24
0
    public IEnumerator PostPlayDataCoroutine()
    {
        if (IsUploading)
        {
            Popup.Make(this, "Already uploading.");
        }

        IsUploading = true;

        EventKit.Broadcast("reload rankings");

        Debug.Log("Posting play data");

        Popup.Make(this, "Uploading play data...");

        yield return(OnlinePlayer.PostPlayData(CytoidApplication.CurrentPlay.IsRanked
            ? (IPlayData)CytoidApplication.CurrentRankedPlayData
            : CytoidApplication.CurrentUnrankedPlayData));

        switch (OnlinePlayer.LastPostResult.status)
        {
        case 200:
            Popup.Make(this, "Uploaded play data.");
            EventKit.Broadcast("profile update");
            SuccessfullyUploaded = true;
            break;

        case 400:
            Popup.Make(this, "ERROR: " + "Invalid play data.");
            uploadButton.interactable = true;
            SuccessfullyUploaded      = false;
            break;

        case 401:
            Popup.Make(this, "ERROR: " + "You haven't signed in.");
            OnlinePlayer.Invalidate();
            uploadButton.interactable = true;
            SuccessfullyUploaded      = false;
            break;

        default:
            Popup.Make(this, "ERROR: " + OnlinePlayer.LastPostResult.message);
            uploadButton.interactable = true;
            SuccessfullyUploaded      = false;
            break;
        }

        IsUploading = false;
        retryButton.interactable = true;
        nextButton.interactable  = true;
    }
예제 #25
0
    public void SwitchDifficulty(string type, bool newLevel)
    {
        if (CytoidApplication.CurrentChartType == type && !newLevel)
        {
            return;
        }
        SetDifficulty(level, level.charts.Find(it => it.type == type));
        CytoidApplication.CurrentChartType = type;
        LevelSelectionController.Instance.UpdateBestText();

        if (PlayerPrefsExt.GetBool("ranked"))
        {
            EventKit.Broadcast("reload rankings");
        }
    }
예제 #26
0
    void PeriodicUpdate()
    {
        QualitySettings.vSyncCount = vSyncEnabled ? 1 : 0;
        debug_AttackDisabled       = !attackEnabled;
        debug_MovementDisabled     = !movementEnabled;

        CheckTileMapStatus();

        if (horizUnitsOnScreen != actualUnitsOnScreen)
        {
            savedUnitsOnScreen = actualUnitsOnScreen;

            EventKit.Broadcast("set screen size", horizUnitsOnScreen);
        }
    }
예제 #27
0
    public void TouchesEnemy(string weaponType, CreatureEntity enemy, Collider2D coll, int hitFrom)
    {
        player.HP -= (int)(enemy.touchDamage * diffDamageModifier);

        EventKit.Broadcast <int>("reduce hp", player.HP);

        if (player.HP > 0)
        {
            MFX.FadeToColorAndBack(spriteRenderer, MCLR.bloodRed, 0f, .2f);
        }
        else
        {
            EventKit.Broadcast <int, Weapon.WeaponType>("player dead", hitFrom, Weapon.WeaponType.Struckdown);
        }
    }
예제 #28
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        if (!alreadyCollided && !levelCompleted && !playerDead)
        {
            int layer = coll.gameObject.layer;

            if (layer == BODY_COLLIDER)
            {
                alreadyCollided = true;

                EventKit.Broadcast <int>("prize collected", 5);

                FadeOutFast();
            }
        }
    }
예제 #29
0
    void PlayerJump()
    {
        velocity.y = Mathf.Sqrt(2f * jumpHeight * -gravity);

        animator.SetBool("jump", true);

        jump = false;

        if (ridingFastPlatform && movingHorizontally)
        {
            if (!jumpedFromFastPlatform)
            {
                jumpedFromFastPlatform = true;
                EventKit.Broadcast <bool>("player jumped from fast platform", true);
            }
        }
    }
    void OnSetDifficulty(int difficulty)
    {
        switch (difficulty)
        {
        case NORMAL:
            EventKit.Broadcast("set difficulty damage modifier", 1);
            break;

        case HARD:
            EventKit.Broadcast("set difficulty damage modifier", 2);
            break;

        case EPIC:
            EventKit.Broadcast("set difficulty damage modifier", 3);
            break;
        }
    }