コード例 #1
0
    //Constructorul bun

    public GenericEnemyBehavior(GameObject _gameObject)
    {
        mGameObject       = _gameObject;
        mTransform        = mGameObject.transform;
        mSamuraiTransform = PlayerReference.instance.mSamuraiGameObject.transform;
        mArcherTransform  = PlayerReference.instance.mArcherGameObject.transform;
        mTargetTransform  = PlayerReference.instance.player.transform;
        mActor            = mGameObject.GetComponent <GenericActor>();
        mAnimator         = mActor.GetAnimator();

        if (mActor == null)
        {
            Debug.LogWarning("Referinta catre Actor din GenericEnemyBehavior este null!!!");
        }

        if (mAnimator == null)
        {
            Debug.LogWarning("Referinta catre Animator din GenericEnemyBehavior este null!");
        }

        b_PhysicsBehavior  = new PhysicsBehavior(mGameObject, mGameObject.GetComponent <Rigidbody2D>());
        b_AnimatorBehavior = new AnimatorBehavior(mGameObject, mActor);

        mBehaviorsList.Add(b_PhysicsBehavior);
        mBehaviorsList.Add(b_AnimatorBehavior);
    }
コード例 #2
0
    //Constructorul bun

    public PlayerBehavior(GameObject _gameObject, Transform _basicAttackPrefab)
    {
        mGameObject         = _gameObject;
        mTransform          = mGameObject.transform;
        mBasicAttackPrefab  = _basicAttackPrefab;
        mTargetingTransform = mTransform.GetChild(1);
        mAnimator           = mTransform.GetChild(0);
        mActor = mGameObject.GetComponent <GenericActor>();

        if (mActor == null)
        {
            Debug.LogWarning("Referinta catre Actor din PlayerBehavior este null!!!");
        }

        if (mAnimator == null)
        {
            Debug.LogWarning("Referinta catre Animator din PlayerBehavior este null!");
        }

        //mMaxSpeed = PlayerReference.instance.playerMaxSpeed;
        mNormalSpeed = GlobalValues.instance.playerNormalSpeed;
        mAirSpeed    = GlobalValues.instance.playerAirSpeed;
        //mJumpTakeOffSpeed = PlayerReference.instance.playerMaxJump;
        mJumpTakeOffSpeed = GlobalValues.instance.jumpForce;

        b_PhysicsBehavior     = new PhysicsBehavior(mGameObject, mGameObject.GetComponent <Rigidbody2D>());
        b_BasicAttackBehavior = new BasicAttackBehavior(mBasicAttackPrefab);
        b_AnimatorBehavior    = new AnimatorBehavior(mGameObject, mActor);

        b_BasicAttackBehavior.AddHitableTag("enemy");

        mBehaviorsList.Add(b_PhysicsBehavior);
        mBehaviorsList.Add(b_BasicAttackBehavior);
        mBehaviorsList.Add(b_AnimatorBehavior);

        mFacingDirection = DIRECTION.RIGHT;
        mTargetingVector = Vector2.right;

        mNormalSprite = mGameObject.GetComponent <SpriteRenderer>().sprite;
        mIsHitSprite  = GlobalSpriteReference.instance.EnemyHit;
    }