Inheritance: MonoBehaviour
Esempio n. 1
0
 public static void Init(GravityManager gravityManager)
 {
     if (_instance == null)
     {
         _instance = new VelocityValues(gravityManager);
     }
 }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        rbody = GetComponent<Rigidbody>();
        rbody.useGravity = false;

        gm = FindObjectOfType<GravityManager>();
    }
Esempio n. 3
0
 private void Awake()
 {
     if (_Instance == null)
     {
         _Instance = this;
     }
 }
Esempio n. 4
0
 private void Awake()
 {
     isOn    = true;
     off     = transform.GetChild(0).position - (transform.GetChild(0).up * 0.2f);
     on      = transform.GetChild(0).position;
     manager = GameObject.Find("GravityManager").GetComponent <GravityManager>();
 }
Esempio n. 5
0
    void Update()
    {
        if (followObject == null || followObject.activeSelf == false)
        {
            if (GameContext.player != null)
            {
                followObject = GameContext.player.gameObject;
            }
            else
            {
                return;
            }
        }
        Transform follow     = followObject.transform;
        Vector3   gravityDir = GravityManager.Instance().gravityDir;
        float     degree     = Vector3.Angle(Vector3.down, gravityDir);

        if (gravityDir.x < 0)
        {
            degree = -degree;
        }
        transform.rotation = Quaternion.Euler(0, 0, degree);
        //transform.LookAt(follow, -GravityManager.Instance().gravityDir);
        //transform.forward = follow.position - transform.position;
        //transform.up = -GravityManager.Instance().gravityDir;
        transform.position = follow.position + cameraOffset;
    }
Esempio n. 6
0
 private void OnDestroy()
 {
     if (instance_ == this)
     {
         instance_ = null;
     }
 }
Esempio n. 7
0
        private void UpdateVelocity()
        {
            if (Math.Abs(Velocity.X) > MaxVelocity.X)
            {
                var value = new Vector2(Math.Sign(Velocity.X) * MaxVelocity.X, Velocity.Y);
                value = GravityManager.ApplyGravity(value);

                value = new Vector2(Math.Abs(value.X), Math.Abs(value.Y));

                value.X *= Math.Sign(Body.LinearVelocity.X);
                value.Y *= Math.Sign(Body.LinearVelocity.Y);

                Body.LinearVelocity = value;
            }

            if (Math.Abs(Velocity.Y) > MaxVelocity.Y)
            {
                var value = new Vector2(Velocity.X, Math.Sign(Velocity.Y) * MaxVelocity.Y);
                value = GravityManager.ApplyGravity(value);

                value = new Vector2(Math.Abs(value.X), Math.Abs(value.Y));

                value.X *= Math.Sign(Body.LinearVelocity.X);
                value.Y *= Math.Sign(Body.LinearVelocity.Y);

                Body.LinearVelocity = value;
            }
        }
Esempio n. 8
0
        public static SpaceStateManager BuildSpaceStateManager(int?areaID, IMessenger messenger, INetworkingService _networkingService)
        {
            //Null references, unused by the Simulator
            TextureManager         textureManager        = null;
            SpriteBatch            spriteBatch           = null;
            ParticleManager        particleManager       = null;
            Texture2D              warpholeTexture       = null;
            Texture2D              borderTexture         = null;
            SelectionManager       selectionManager      = null;
            IGlobalGameUISingleton globalGameUISingleton = null;


            MessageService_ToServer  messageService          = new MessageService_ToServer(messenger);
            SimulationManager        simulationManager       = new SimulationManager();
            CollisionManager         collisionManager        = new CollisionManager(messageService);
            PlayerShipManager        playerShipManager       = new PlayerShipManager(messageService);
            IClientPlayerInfoManager clientPlayerInfoManager = new PlayablePlayerInfoManager(playerShipManager);
            TargetingService         targetingService        = new TargetingService();
            TeamManager       teamManager       = new TeamManager(targetingService);
            PhysicsManager    physicsManager    = new PhysicsManager();
            BorderManager     borderManager     = new BorderManager(borderTexture, spriteBatch, physicsManager);
            ProjectileManager projectileManager = new ProjectileManager(particleManager, physicsManager.World, spriteBatch, targetingService, simulationManager, messageService, collisionManager);
            ClientShipManager clientShipManager = new ClientShipManager(particleManager, playerShipManager, spriteBatch, textureManager, simulationManager, targetingService, teamManager, projectileManager, messageService, clientPlayerInfoManager, true);

            clientShipManager.SendPositionUpdates = true;
            StructureFactoryManager structureFactoryManager = new StructureFactoryManager(messageService, physicsManager.World, projectileManager, targetingService, teamManager, null, clientShipManager, null, true);
            WarpHoleManager         warpholeManager         = new WarpHoleManager(messageService, particleManager, physicsManager, clientShipManager, warpholeTexture);
            GravityManager          gravityManager          = new GravityManager(physicsManager);
            SpaceObjectManager      spaceObjectManager      = new SpaceObjectManager(textureManager, messageService, spriteBatch, particleManager, physicsManager);
            SpaceManager            spaceManager            = new SpaceManager(spriteBatch, borderManager, gravityManager, physicsManager, spaceObjectManager, warpholeManager);
            FloatyAreaObjectManager floatyAreaObjectManager = new FloatyAreaObjectManager(physicsManager.World, textureManager, messageService, spriteBatch, particleManager);

            var mhi = areaID == null ? new MessageHandlerID() : new MessageHandlerID((int)areaID);



            SpaceStateManager spaceStateManager = new SpaceStateManager(mhi,
                                                                        clientPlayerInfoManager,
                                                                        globalGameUISingleton,
                                                                        collisionManager,
                                                                        _networkingService,
                                                                        physicsManager,
                                                                        playerShipManager,
                                                                        projectileManager,
                                                                        selectionManager,
                                                                        simulationManager,
                                                                        clientShipManager,
                                                                        spaceManager,
                                                                        structureFactoryManager,
                                                                        targetingService,
                                                                        teamManager,
                                                                        warpholeManager,
                                                                        messageService,
                                                                        floatyAreaObjectManager);

            spaceStateManager.SetAreaId(areaID);

            return(spaceStateManager);
        }
Esempio n. 9
0
    public ShockWaveDebris(Vector3 direction, Vector3 location, float speedFactor, GravityManager gravityManager, float lifeTime, Object sampleDebris)
    {
        m_direction   = direction.normalized;
        m_speedFactor = speedFactor;

        m_pieceOfDebris = (GameObject)Object.Instantiate(sampleDebris, location, Random.rotation);
        GameObject.Destroy(m_pieceOfDebris, lifeTime);
    }
Esempio n. 10
0
    void jump()
    {
        Vector3 gravityDir = GravityManager.Instance().gravityDir;

        rbody.AddForce(gravityDir * -jumpImpulse, ForceMode.Impulse);
        //playerState = PlayerState.Jump;
        TimeManager.Instance().timeDictionary["jumpDelay"] = jumpDelay;
    }
Esempio n. 11
0
 private void Start()
 {
     gravity = FindObjectOfType <GravityManager>();
     if (gravity == null)
     {
         Debug.LogError("No Gravity Manager :(");
     }
 }
Esempio n. 12
0
 private void Start()
 {
     m_Input        = GetComponent <InputManager>();
     m_State        = gameObject.GetComponent <FallingState>();
     m_Collision    = gameObject.GetComponent <CollisionManager>();
     m_CurrentState = m_State.GetStateName();
     m_Grav         = gameObject.GetComponent <GravityManager>();
 }
Esempio n. 13
0
 private void SpawnDebris(int amount, GravityManager gravityManager, Object sampleDebris)
 {
     for (int i = 0; i < amount; i++)
     {
         Vector3 randomDirection = Random.onUnitSphere;
         m_shockWaveDebris.Add(new ShockWaveDebris(randomDirection, location, Random.Range(0.8f, 1.2f), gravityManager, lifeTime, sampleDebris));
     }
 }
Esempio n. 14
0
 private void Awake()
 {
     m_CoinFSM        = new FSM <CoinBehavior>(this);
     m_SpeedManager   = GetComponent <SpeedManager>();
     m_GravityManager = GetComponent <GravityManager>();
     m_Collider2D     = GetComponent <Collider2D>();
     m_TrailRenderer  = GetComponent <TrailRenderer>();
 }
Esempio n. 15
0
 //Initialize vars and managers
 void Start()
 {
     PropertiesPanel.SetActive(true);
     GlobOptionPanel.SetActive(true);
     socas = Selected.GetComponent <SelectedObjectControllerAndSelecter>();
     rbm   = Selected.GetComponent <RigidBodyManager>();
     gm    = gameObject.GetComponent <GravityManager>();
     pbc   = GameObject.FindWithTag("PlayButton").GetComponent <PlayButtonController>();
 }
Esempio n. 16
0
            private void Update()
            {
                IsGrounded = Physics.CheckSphere(_worldSpaceFeetPosition, _groundDetectionRadius, ~_ignoreLayers);
                GetInput();

                Vector3 normalizedGravity = GravityManager.CalculateGravityAtPosition(transform.position).normalized;

                ApplyRotation(normalizedGravity);
            }
Esempio n. 17
0
    void FixedUpdate()
    {
        GravityManager manager = GravityManager.Instance();

        if (manager != null)
        {
            rbody.AddForce(manager.gravityDir * manager.gravityMagnitude);
        }
    }
Esempio n. 18
0
    void Start()
    {
        shipCounter = gameObject.GetComponent <ShipCounter>();

        teamOneCount.text = "#0";
        teamTwoCount.text = "#0";

        gravityManager = new GravityManager(this, m_spawners);
    }
Esempio n. 19
0
 // Use this for initialization
 void Start()
 {
     GM = GameObject.Find("GravityManager").GetComponent<GravityManager>();
     GM.GravityBodyList.Add(this);
     if(HasProjection)
     {
         MyLR = this.gameObject.GetComponent<LineRenderer>();
     }
 }
Esempio n. 20
0
 static public void Init()
 {
     if (instance == null)
     {
         instance          = new GravityManager();
         instance.dataBase = DataManager.Instance.addData("GravityControllerData");
         instance.Bind(instance.ChangeStatus);
         instance.dataBase.SetNumberValue("gravityScale", EncryptionManager.GetDouble("gravityScale", 0.5));
     }
 }
Esempio n. 21
0
 private static void OutputLeaf(TextWriter writer, LeafNode node, GravityNode rootNode, string prefix1, string prefix2)
 {
     writer.Write(prefix1);
     writer.Write("Mass: ");
     writer.Write(node.Mass);
     writer.Write("\tCentre of mass: ");
     writer.Write(node.CentreOfMass);
     writer.Write("\tForce: ");
     writer.WriteLine(GravityManager.CalculateTreeForce(node, rootNode));
 }
Esempio n. 22
0
    void Start()
    {
        bc = GetComponent <BoxCollider>();

        if ((transform.parent != null))
        {
            gm = transform.parent.gameObject.GetComponent <GravityManager>();
        }

        canPlay = (reverseCollider != null) && (gm != null) && (gm.points.Count > 0) && (indexGravityNode >= 0) && (gm.points.Count > indexGravityNode);
    }
Esempio n. 23
0
 // Use this for initialization
 void Awake()
 {
     if (!instance)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
Esempio n. 24
0
            private void FixedUpdate()
            {
                bool rbIsAwake = !_rigidbody.IsSleeping();
                bool awake     = _rigidbody.velocity.magnitude > _sleepThreshold || (!_rbWasAwake && rbIsAwake);

                if (_useGravityInternal && awake)
                {
                    _rigidbody.AddForce(GravityManager.CalculateGravityAtPosition(transform.position), ForceMode.Acceleration);
                }

                _rbWasAwake = rbIsAwake;
            }
Esempio n. 25
0
    // Use this for initialization
    void Start()
    {
        gm = GameObject.FindObjectOfType <GravityManager>();

        gravityDirection = "down";
        if (moveSpeed == 0)
        {
            moveSpeed = 7f;
        }

        print("Yo im a cube. Called from the start");
    }
Esempio n. 26
0
    void Update()
    {
        Vector3 gravityDir = GravityManager.Instance().gravityDir;
        float   degree     = Vector3.Angle(Vector3.down, gravityDir);

        if (gravityDir.x < 0)
        {
            degree = -degree;
        }
        transform.rotation = Quaternion.Euler(0, 0, degree);
        HandleInput();
    }
Esempio n. 27
0
    // Use this for initialization
    void Start()
    {
        rbody            = GetComponent <Rigidbody>();
        rbody.useGravity = false;

        gm = FindObjectOfType <GravityManager>();

        if (gm != null)
        {
            FindClosesPointOnSpline();
        }
    }
    void FlipSprite(GravityManager grav)
    {
        switch (grav.m_GravityDirection)
        {
        case GravityManager.GravityDirection.Down:
            if (walkDir.x < 0)
            {
                sprite.flipX = true;
            }
            else if (walkDir.x > 0)
            {
                sprite.flipX = false;
            }
            break;

        case GravityManager.GravityDirection.Up:
            if (walkDir.x > 0)
            {
                sprite.flipX = true;
            }
            else if (walkDir.x < 0)
            {
                sprite.flipX = false;
            }
            break;

        case GravityManager.GravityDirection.Right:
            if (walkDir.y < 0)
            {
                sprite.flipX = true;
            }
            else if (walkDir.y > 0)
            {
                sprite.flipX = false;
            }
            break;

        case GravityManager.GravityDirection.Left:
            if (walkDir.y > 0)
            {
                sprite.flipX = true;
            }
            else if (walkDir.y < 0)
            {
                sprite.flipX = false;
            }
            break;

        default:
            break;
        }
    }
Esempio n. 29
0
 void Start()
 {
     _instance = this;
     if (GameContext.spawnGravity == Vector3.zero)
     {
         gravityDir = new Vector3(0, -1, 0);
     }
     else
     {
         gravityDir = GameContext.spawnGravity.normalized;
     }
     targetGravityDir = gravityDir;
 }
Esempio n. 30
0
        public MechanicControler(Hero hero, World world, GravityManager gravityManager)
        {
            Platman        = hero;
            Body           = hero.Body;
            World          = world;
            MaxVelocity    = new Vector2(8f, Math.Abs(VelocityValues.Instance.Down.Y));
            GravityManager = gravityManager;

            Body.OnCollision  += Body_OnCollision;
            Body.OnSeparation += Body_OnSeparation;

            input = PlayerInput.Instance;
            keys  = HeroKeys.Instance;
        }
Esempio n. 31
0
    private void Awake()
    {
        if (instance_ == null)
        {
            instance_ = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        GravityManager.globalGravityFactor = globalGravityFactor_;
    }
Esempio n. 32
0
        // Area for declaring variables pertaining to the list of planets.

        /// <summary>
        /// Creates system with Planets and Borders
        /// </summary>
        public SpaceManager(SpriteBatch spriteBatch,
                            BorderManager borderManager,
                            GravityManager gravityManager,
                            PhysicsManager physicsManager,
                            SpaceObjectManager spaceObjectManager,
                            WarpHoleManager warpholeManager)
        {
            r = new Random(45546);
            _physicsManager  = physicsManager;
            _warpholeManager = warpholeManager;

            _spaceObjectManager = spaceObjectManager;
            _borderManager      = borderManager;
            _gravityManager     = gravityManager;
        }
Esempio n. 33
0
 private void Awake()
 {
     // This object needs to persist through scenes.
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     else
     {
         Destroy(this.gameObject);
     }
     // Hold a reference to the original gravity.
     originalGravity = Physics.gravity;
     // Subscribe to the events where scene changes happen.
     SceneTransition.SceneChangeStarted  += DisableGravity;
     SceneTransition.SceneChangeFinished += EnableGravity;
 }
Esempio n. 34
0
 void OnDestroy()
 {
     eventGravitation = null;
     instance = null;
 }
 void Awake()
 {
     _target = target as GravityManager;
     ReloadSerializedProperties();
 }
 public GlobalGravityChannel(GravityManager.GravityChannels channel)
 {
     this.channel = channel;
 }
Esempio n. 37
0
 // Use this for initialization
 void Start()
 {
     GM = GameObject.Find("GravityManager").GetComponent<GravityManager>();
     GM.GravityAttractorList.Add(this);
 }