Example #1
0
    public void OnAction(GameEventData gameEventData)
    {
        CameraController cameraController  = GameController.Instance.CameraControllerInstance;
        Vector3          cameraPosition    = cameraController.transform.position;
        float            frustumHalfHeight = Mathf.Abs(cameraPosition.z) * Mathf.Tan(cameraController.CameraComponent.fieldOfView * 0.5f * Mathf.Deg2Rad);
        float            cameraTopBound    = cameraPosition.y + frustumHalfHeight;

        cameraTopBound += 2.0f;             // idk arbitrary thing so the bomb's center isn't right on the screen edge but slightly outside

        for (int i = 0; i < gameEventData.Number; ++i)
        {
            float   x             = Random.Range(-gameEventData.Offset.x, gameEventData.Offset.x);
            float   y             = Random.Range(-gameEventData.Offset.y, gameEventData.Offset.y);
            Vector3 offset        = new Vector2(x, y).ToVec3();
            Vector3 spawnPosition = new Vector2(gameEventData.Position.x, cameraTopBound + gameEventData.Position.y).ToVec3();

            float   spread  = Random.Range(-gameEventData.Spread, gameEventData.Spread);
            float   radians = (gameEventData.Rotation + spread) * Mathf.Deg2Rad;
            float   cos     = Mathf.Cos(radians);
            float   sin     = Mathf.Sin(radians);
            Vector2 force   = new Vector3(cos, sin) * gameEventData.Speed.Get();

            MonoBehaviour bomb = Object.Instantiate(gameEventData.Object);
            bomb.transform.Reset();
            bomb.transform.position = spawnPosition + offset;
            BSGFakePhysics fakePhysics = bomb.GetComponent <BSGFakePhysics>();
            if (fakePhysics != null)
            {
                fakePhysics.AddForce(force);
            }
        }
    }
Example #2
0
    private bool TryThrowObject()
    {
        if (mGrabbedObject != null)
        {
            // Do type-specific actions here.
            Missile missile = mGrabbedObject.gameObject.GetComponent <Missile>();
            if (missile != null)
            {
                missile.SetState(Missile.EMissileState.Flying);
            }
        }

        if (mGrabbedObject == null)
        {
            return(false);
        }

        Vector2 force = mThrowDirection * mThrowForce;

        mGrabbedObject.enabled              = true;
        mGrabbedObject.Velocity             = force;
        mGrabbedObject.transform.localScale = Vector3.one;
        mGrabbedObject = null;

        if (!Owner.FakePhysics.IsGrounded || mHasKnockbackOnGround)
        {
            Owner.FakePhysics.Velocity = -mThrowDirection * mKnockbackForce;
        }
        if (!Owner.FakePhysics.IsGrounded || mHasStunOnGround)
        {
            Owner.OverrideController.ApplyCharacterOverrides(mCharacterPostThrowState, mCharacterPostThrowStateDuration);
        }

        return(true);
    }
Example #3
0
    private void Awake()
    {
        mOwner       = GetComponent <Character>();
        mFakePhysics = GetComponent <BSGFakePhysics>();
        mTriggerable = GetComponent <Triggerable>();

        mTriggerable.OnPreTimedEvent  += OnPreTimedEvent;
        mTriggerable.OnPostTimedEvent += OnPostTimedEvent;
    }
Example #4
0
    private void Awake()
    {
        mMovementController = GetComponent <CharacterMovementController>();
        mOverrideController = GetComponent <CharacterOverrideController>();
        mAbilityController  = GetComponent <CharacterAbilityController>();

        mFakePhysics = GetComponent <BSGFakePhysics>();
        mTriggerable = GetComponent <Triggerable>();
    }
Example #5
0
    private void Awake()
    {
        mFakePhysics              = GetComponent <BSGFakePhysics>();
        mFakePhysics.OnImpact    += OnImpact;
        mTriggerable              = GetComponent <Triggerable>();
        mTriggerable.OnTriggered += Trigger;

        mAnimationComponent = GetComponentInChildren <Animation>();
        mAnimationComponent.AddClip(mIdleAnimation, ANIMATION_IDLE);
        mAnimationComponent.AddClip(mIgniteAnimation, ANIMATION_IGNITE);
        mAnimationComponent.Play(ANIMATION_IDLE);
    }
Example #6
0
    private void Awake()
    {
        mCollisionMask         = Globals.GetCollisionMask(gameObject);
        mCurrentTime           = mTrackingTime;
        mTrailRenderer         = GetComponent <TrailRenderer>();
        mFakePhysics           = GetComponent <BSGFakePhysics>();
        mFakePhysics.OnImpact += OnImpact;
        mRenderers             = GetComponentsInChildren <Renderer>();

        SetState(EMissileState.Tracking);

        transform.position = Vector3.up * 100.0f;
    }
Example #7
0
    private bool TryPickupObject()
    {
        Collider[] colliders = Physics.OverlapSphere(GetCurrentGrabSocketPosition(Space.World), mGrabRadius);
        for (int i = 0; i < colliders.Length; ++i)
        {
            if (colliders[i].gameObject == Owner.gameObject)
            {
                continue;
            }

            BSGFakePhysics fakePhysics = colliders[i].gameObject.GetComponent <BSGFakePhysics>();
            if (fakePhysics == null || !fakePhysics.enabled)
            {
                continue;
            }

            mGrabbedObject      = fakePhysics;
            fakePhysics.enabled = false;
            fakePhysics.transform.localScale = Vector3.one * 0.5f;

            mThrowDirection = Owner.MovementController.IsFacingRight ? Vector3.right : Vector3.left;

            // Do type-specific actions here.
            Bomb bomb = fakePhysics.gameObject.GetComponent <Bomb>();
            if (bomb != null)
            {
                if (mThrowTriggerExplosion == true)
                {
                    bomb.CanBeTriggerByImpact = mThrowTriggerExplosion;
                }
            }
            Missile missile = fakePhysics.gameObject.GetComponent <Missile>();
            if (missile != null)
            {
                missile.SetState(Missile.EMissileState.Grabbed);
            }

            return(true);
        }

        return(false);
    }
    private void Update()
    {
        if (BombPrefabs.Length > 0 && mBombsPerSecond > 0.0f)
        {
            mSpawnTimer += Time.deltaTime;
            float depth    = GameController.Instance.FurthestDepth;
            float interval = 1.0f / Mathf.Min(mBombsPerSecond + mRampPerDepth * depth, mMaxBombsPerSecond != 0.0f ? mMaxBombsPerSecond : float.MaxValue);
            if (mSpawnTimer >= interval)
            {
                mSpawnTimer -= interval;

                Vector2 force = new Vector2(Random.Range(0.0f, 0.0f), 0.0f);

                MonoBehaviour bomb = Instantiate(BombPrefabs.GetRandom());
                bomb.transform.Reset();
                bomb.transform.position = new Vector2(Random.Range(-8.0f, 8.0f), 10.0f);
                BSGFakePhysics fakePhysics = bomb.GetComponent <BSGFakePhysics>();
                if (fakePhysics != null)
                {
                    fakePhysics.AddForce(force);
                }
            }
        }
    }