GetObjectExtra() public method

public GetObjectExtra ( string paramName ) : object
paramName string
return object
Example #1
0
    private void Spawn(Parameters parameters)
    {
        if (!this.objectPool.HasObjectAvailable(1))
        {
            return;
        }
        var newEnemy = (Enemy)this.objectPool.RequestPoolable();

        var direction  = (Direction)parameters.GetObjectExtra(PARAM_DIRECTION);
        var enemyClass = (EnemyClass)parameters.GetObjectExtra(PARAM_ENEMYCLASS);

        // Update enemy direction
        newEnemy.SetEnemyClass(enemyClass);
        newEnemy.ChangeDirection(direction);

        // Update layer
        if (direction == Direction.UP)
        {
            newEnemy.GetComponent <Renderer>().sortingLayerName = SortingLayerNames.CUSTOMER_TOP;
            newEnemy.GetComponent <Renderer>().sortingOrder     = Math.Abs(spawnedCount);
        }
        else
        {
            newEnemy.GetComponent <Renderer>().sortingLayerName = SortingLayerNames.CUSTOMER;
            newEnemy.GetComponent <Renderer>().sortingOrder     = spawnedCount;
        }

        // Decrease spawn count
        this.spawnedCount--;

        spawnedEnemyQueue.Enqueue(newEnemy);
    }
Example #2
0
    /// <summary>
    /// Update the stability.
    /// </summary>
    /// <param name="parameters">Parameter containing the ghost block which will affect the stability.</param>
    public void HollowUpdate(Parameters parameters)
    {
        float       numerator   = parameters.GetFloatExtra(NUMERATOR, 0f);
        float       denominator = parameters.GetFloatExtra(DENOMINATOR, 1f);
        Color       color       = (Color)parameters.GetObjectExtra(COLOR);
        bool        isAdd       = parameters.GetBoolExtra(IS_ADD, true);
        HollowBlock block       = (HollowBlock)parameters.GetObjectExtra(HOLLOW_BLOCK);

        this.ManipulateStability(numerator, denominator, color, isAdd, block);
        //		StabilityCheck ();
    }
Example #3
0
    /// <summary>
    /// Update the stability.
    /// </summary>
    /// <param name="parameters">Parameter containing the ghost block which will affect the stability.</param>
    public void HollowUpdateInstant(Parameters parameters)
    {
        Debug.LogError("Entered instant");
        float       numerator   = parameters.GetFloatExtra(NUMERATOR, 0f);
        float       denominator = parameters.GetFloatExtra(DENOMINATOR, 1f);
        Color       color       = (Color)parameters.GetObjectExtra(COLOR);
        bool        isAdd       = parameters.GetBoolExtra(IS_ADD, true);
        HollowBlock block       = (HollowBlock)parameters.GetObjectExtra(HOLLOW_BLOCK);

        StartCoroutine(this.ManipulateStability(numerator, denominator, color, isAdd, block, true));
        //		StabilityCheck ();
    }
Example #4
0
    void SetPlayerType(Parameters param)
    {
        type = (PlayerType)param.GetObjectExtra(PLAYER_TYPE_KEY);

        GetComponent <SpriteRenderer> ().sprite = type.defaultSprite;
        GetComponent <Animator> ().runtimeAnimatorController = type.animator;
    }
Example #5
0
    /// <summary>
    /// Called when the player avatar is damaged.
    ///
    /// Decreases the health meter's scale.
    /// </summary>
    /// <param name="parameters"></param>
    void OnPlayerDamage(Parameters parameters)
    {
        PlayerHealth playerHealth = parameters.GetObjectExtra("playerHealth") as PlayerHealth;

        this.maxHp     = playerHealth.GetMaxHp();
        this.currentHp = playerHealth.CurrentHealth();
//		this.UpdateHealthLength ();
        this.UpdateHealthCircle(this.currentHp, this.maxHp);
    }
    private void OnReceiveUnitPosition(Parameters parameters)
    {
        Vector3 viewportPos = (Vector3) parameters.GetObjectExtra(UNIT_POSITION_KEY);
        Vector3 unitPos = Vector3.zero;
        unitPos.x = viewportPos.x * UIStats.Instance.GetReferenceWidth();
        unitPos.y = viewportPos.y * UIStats.Instance.GetReferenceHeight();

        ControllableUnit unit = (ControllableUnit) parameters.GetObjectExtra(CONTROLLABLE_UNIT_KEY);

        //instantiate hp bar prefab.
        HPBarElement hpBar = GameObject.Instantiate(hpBarPrefab) as HPBarElement;
        hpBar.transform.gameObject.name = this.hpBarPrefab.name;
        hpBar.transform.localPosition = unitPos;
        hpBar.transform.SetParent(this.transform, false);
        hpBar.AssignControllableUnit(unit);

        this.hpBarList.Add(hpBar);
    }
    private void OnReceivedPictureClickedEvent(Parameters parameters)
    {
        PictureModel          pictureModel         = (PictureModel)parameters.GetObjectExtra(GameMechanicHandler.PICTURE_MODEL_KEY);
        IPictureMatchListener pictureMatchListener = (IPictureMatchListener)parameters.GetObjectExtra(GameMechanicHandler.PICTURE_MATCH_LISTENER_KEY);

        if (this.firstPicture == null)
        {
            this.firstPicture  = pictureModel;
            this.firstListener = pictureMatchListener;
        }
        else if (this.secondPicture == null)
        {
            this.secondPicture  = pictureModel;
            this.secondListener = pictureMatchListener;

            //verify if both are matched
            if (this.firstPicture.GetPictureType() == this.secondPicture.GetPictureType())
            {
                this.firstListener.OnMatchValid();
                this.secondListener.OnMatchValid();

                EventBroadcaster.Instance.PostEvent(EventNames.ON_UPDATE_SCORE);
                EventBroadcaster.Instance.PostEvent(EventNames.ON_CORRECT_MATCH);
            }
            else
            {
                this.firstListener.OnMatchInvalid();
                this.secondListener.OnMatchInvalid();

                EventBroadcaster.Instance.PostEvent(EventNames.ON_WRONG_MATCH);
            }

            //set to null after checking
            this.firstPicture  = null;
            this.secondPicture = null;

            this.firstListener  = null;
            this.secondListener = null;
        }
        else
        {
            Debug.LogWarning("[GameMechanicHandler] Error. Both picture models are stored already!");
        }
    }
Example #8
0
    public void ShowEndScreen(Parameters param)
    {
        gameObject.SetActive(true);

        PlayerManager winner = param.GetObjectExtra(WINNER) as PlayerManager;

        this.SetWinner(winner.GetPlayerHero().GetHero());
        GetEndScreenAnimatable().Show();
        SoundManager.Instance.Play(AudibleNames.Target.GET);
    }
    private void OnReceiveUnitPosition(Parameters parameters)
    {
        Vector3 viewportPos = (Vector3)parameters.GetObjectExtra(UNIT_POSITION_KEY);
        Vector3 unitPos     = Vector3.zero;

        unitPos.x = viewportPos.x * UIStats.Instance.GetReferenceWidth();
        unitPos.y = viewportPos.y * UIStats.Instance.GetReferenceHeight();

        ControllableUnit unit = (ControllableUnit)parameters.GetObjectExtra(CONTROLLABLE_UNIT_KEY);

        //instantiate hp bar prefab.
        HPBarElement hpBar = GameObject.Instantiate(hpBarPrefab) as HPBarElement;

        hpBar.transform.gameObject.name = this.hpBarPrefab.name;
        hpBar.transform.localPosition   = unitPos;
        hpBar.transform.SetParent(this.transform, false);
        hpBar.AssignControllableUnit(unit);

        this.hpBarList.Add(hpBar);
    }
Example #10
0
    public void ReduceHealth(Parameters parameters)
    {
        PlayerManager playerReduced = parameters.GetObjectExtra(PLAYER_REDUCED) as PlayerManager;

        if (playerReduced == this.GetPlayer())
        {
            hpInstances[hpInstances.Length - 1].SetMaterial(General.GetLifeEmptyMaterial()); //.GetComponent<Animator>().SetTrigger(HP_ANIM_DISAPPEAR);
            Array.Resize <LifeBarObjectMarker>(ref hpInstances, hpInstances.Length - 1);
            Debug.Log("new array size: " + hpInstances.Length);
        }
    }
Example #11
0
    void punch(Parameters parameters)
    {
        Direction direction = (Direction)parameters.GetObjectExtra(EnemyMechanicHandler.PARAM_DIRECTION);

        int randomFoodIndex = (int)Random.Range(0, foods.Length);

        currentFood.SetActive(false);
        currentFood = foods [randomFoodIndex];
        currentFood.SetActive(true);

        StartCoroutine(playPunchAnimation(direction));
    }
Example #12
0
    void HitEnemyByDirection(Parameters parameters)
    {
        var direction = (Direction)parameters.GetObjectExtra(PARAM_DIRECTION);
        var enemy     = HitHandler.Instance.GetEnemyInDirection(direction);

        if (enemy == null)
        {
            return;
        }

        HitEnemy(enemy);
    }
Example #13
0
    public void UpdateRule(Parameters param)
    {
        RuleInfo ruleInfo = param.GetObjectExtra(RULE_PARAM) as RuleInfo;

        if (ruleInfo.rule == Rules.TEXT_ONLY)
        {
            ruleText.SetRuleText(ruleInfo.forceText);
        }
        else
        {
            ruleText.SetRuleText(ruleInfo.rule.ToRuleText());
        }
    }
    // For player fragment label
    public void SkyOverlapUpdate(Parameters parameters)
    {
        SkyFragmentPiece overlappingPiece = parameters.GetObjectExtra(OVERLAPPING_PIECE) as SkyFragmentPiece;

        if (overlappingPiece != null)
        {
            this.UpdateLabel((int)overlappingPiece.GetNumerator(), (int)overlappingPiece.GetDenominator());
            this.ShowHint();
        }
        else
        {
            this.HideHint();
        }
    }
    public void LiftOverlapUpdate(Parameters parameters)
    {
        HollowBlock overlappingPiece = parameters.GetObjectExtra(OVERLAPPING_PIECE) as HollowBlock;

        if (overlappingPiece != null)
        {
            this.UpdateLabel((int)overlappingPiece.GetNumerator(), (int)overlappingPiece.GetDenominator());
            this.ShowHint();
        }
        else
        {
            this.HideHint();
        }
    }
Example #16
0
 void VerifyLock(Parameters param)
 {
     General.LogEntrance("VerifyLock");
     if (!GameMaster.Instance.GetHasVerified())
     {
         PlayerManager player = param.GetObjectExtra(GameMaster.PLAYER) as PlayerManager;
         if (player == GameMaster.Instance.GetCurPlayer())
         {
             Unlock();
             GameMaster.Instance.SetHasVerified(true);
             Debug.Log("verify player");
         }
     }
 }
Example #17
0
    void OnHitCustomer(Parameters p)
    {
        var enemy     = (Enemy)p.GetObjectExtra(SERVED_CUSTOMER_KEY);
        var direction = (Direction)p.GetObjectExtra(SERVED_DIR_CUSTOMER_KEY);

        enemy.SetFood(currentFood.GetComponent <SpriteRenderer>().sprite);

        if (direction == Direction.UP)
        {
            SmokeN.Play();
        }
        if (direction == Direction.LEFT)
        {
            SmokeW.Play();
        }
        if (direction == Direction.RIGHT)
        {
            SmokeE.Play();
        }
        if (direction == Direction.DOWN)
        {
            SmokeS.Play();
        }
    }
Example #18
0
    void HitAllEnemy(Parameters parameters)
    {
        var enemyListParam = parameters.GetObjectExtra(PARAM_ENEMYLIST);

        if (enemyListParam == null)
        {
            return;
        }

        var enemyList = (Enemy[])enemyListParam;

        for (var i = 0; i < enemyList.Length; i++)
        {
            HitEnemy(enemyList[i]);
        }
    }
    // TODO
    public void UpdateCarriedLift(Parameters parameters)
    {
        HollowBlock piece = parameters.GetObjectExtra(HOLLOW_BLOCK) as HollowBlock;

//		this.skyPiece = piece;
        this.hollowBlock = piece;
        // Safety measure. Should never enter this.
        if (this.hollowBlock == null)
        {
            DropLift();
        }
        else
        {
            this.SetSize(this.hollowBlock.GetWidthPiece(), this.hollowBlock.GetHeight());
            this.ChangeColor(this.hollowBlock.GetTangibleColor(), this.hollowBlock.GetOutlineStartColor());
            this.spriteRenderer.material = hollowBlock.GetSpriteRenderer().material;
            this.GetFractionLabel().Show();
            this.SetFractionLabel((int)this.hollowBlock.GetNumerator(), (int)this.hollowBlock.GetDenominator());
        }
    }
    public void UpdateCarriedGem(Parameters parameters)
    {
        SkyFragmentPiece piece = parameters.GetObjectExtra(SKY_PIECE) as SkyFragmentPiece;

        this.skyPiece = piece;

        // Safety measure. Should never enter this.
        if (this.skyPiece == null)
        {
            DropGem();
        }
        else
        {
            this.SetSize(this.skyPiece.GetWidth(), this.skyPiece.GetHeight());
            this.ChangeColor(this.skyPiece.GetFillColor(), this.skyPiece.GetOutlineColor());
            this.spriteRenderer.material = skyPiece.GetSpriteRenderer().material;
            this.GetFractionLabel().Show();
            this.SetFractionLabel((int)this.skyPiece.GetNumerator(), (int)this.skyPiece.GetDenominator());
        }
    }
Example #21
0
    void OnBlockClicked(Parameters parameter)
    {
        if (LevelManager.Instance.IsGameOver())
        {
            return;
        }

        var key = (KeyCode)parameter.GetObjectExtra(PARAM_KEY_PRESSED);

        var targetColor = (BlockColor)parameter.GetIntExtra(PARAM_TARGETCOLOR, 0);
        var isCorrect   = false;

        if ((key == attachedPlayer.keyRed && targetColor == BlockColor.RED) ||
            (key == attachedPlayer.keyGreen && targetColor == BlockColor.GREEN) ||
            (key == attachedPlayer.keyBlue && targetColor == BlockColor.BLUE))
        {
            EventBroadcaster.Instance.PostEvent(EventNames.ON_CORRECT);
            EventBroadcaster.Instance.PostEvent(EventNames.REMOVE_BLOCK);
            return;
        }

        EventBroadcaster.Instance.PostEvent(EventNames.ON_WRONG);
    }
Example #22
0
    private void OnBeaconDetected(Parameters parameters)
    {
        Vector3 target = (Vector3)parameters.GetObjectExtra(BeaconTarget.BEACON_POSITION_KEY);

        this.MoveAllAgents(target);
    }