public CubeSet(PhysicsController physicsController, TextureStore textureStore, Vector2 position, int playnum, PhysicsGame.Game1.RoundSpecific cr)
        {
            currentRound           = cr;
            this.textureStore      = textureStore;
            this.physicsController = physicsController;
            //sound = s;
            if (playnum == 1)
            {
                ID = PhysicsGameObject.PhysicsMapID.player1;
            }
            else
            {
                ID = PhysicsGameObject.PhysicsMapID.player2;
            }

            CubeNode rootNode = createNode(new CubeDescription(CubeType.PlainCube));

            rootNode.physicalObject.boxBody.Position = position;

            cubeLookUp                         = new Dictionary <Vector2, CubeNode>();
            rootNode.positionIndex             = new Vector2();
            cubeLookUp[rootNode.positionIndex] = rootNode;

            changeSelecetedNode(rootNode.positionIndex);

            rootNode.physicalObject.boxBody.Position = position;
        }
Esempio n. 2
0
    // ====================================================
    public void Initialize()
    {
        prevPos      = VectorUtils.GetPosition2D(transform.position);
        nextFireTime = MinigameTimeManager.instance.time;

        joystickController = GetComponent <JoystickController>();
        joystickController.Initialize();

        MinigameTimeManager.instance.onTimeScaleChanged += OnTimeScaleChangedHandler;

        Director.instance.OnPlayerSpawn(this);

        physicsController = GetComponent <PhysicsController>();
        physicsController.shouldUseSlopes = true;
        physicsController.SetCollisionLayers(LayerMask.GetMask(new string[] { "InvisibleWallLayer", "LevelLayer", "MoveBoxLayer" }),
                                             LayerMask.GetMask(new string[] { "InvisibleWallLayer", "LevelLayer", "MoveBoxLayer", "OneWayPlatformLayer" }));

        physicsController.Initialize();

        hitboxReferences = GetComponentsInChildren <PlayerHitboxReference>();
        foreach (PlayerHitboxReference hitboxReference in hitboxReferences)
        {
            hitboxReference.player = this;
        }
        isDead = false;
    }
Esempio n. 3
0
 void Awake()
 {
     player      = GetComponent <PhysicsController>();
     cc          = GetComponent <CharController>();
     loopTracker = GetComponent <LoopTracker>();
     cannon      = GetComponent <CannonLookAtMouse>();
 }
Esempio n. 4
0
        private List <Point[]> CalculateContiniousPath()
        {
            const float MAX_DISTANCE = 100;
            const float PATH_STEP    = 1f;

            var objects = world.Objects.Select(x => x.Clone()).ToList();
            //objects.Add(launchObject);

            var objectsPath = new Dictionary <GravityObject, List <Point> >();

            for (var i = 0f; i < MAX_DISTANCE; i += PATH_STEP)
            {
                foreach (var obj in objects)
                {
                    if (!objectsPath.ContainsKey(obj))
                    {
                        objectsPath.Add(obj, new List <Point>());
                    }

                    objectsPath[obj].Add(new Point((int)obj.Position.X, (int)obj.Position.Y));

                    PhysicsController.CalcStepFor(obj, objects, PATH_STEP);

                    obj.Position += obj.Velocity * PATH_STEP;
                }
            }

            return(objectsPath.Select(x => x.Value.ToArray()).ToList());
        }
Esempio n. 5
0
 void Awake()
 {
     meshFilter        = GetComponent <MeshFilter>();
     physicsController = GetComponent <PhysicsController>();
     // Set placeholder bounding box.
     boundingBox = new Bounds(transform.position, transform.localScale);
 }
Esempio n. 6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            floorTiles = Content.Load <Texture2D>("TempleFloor.png");
            //playerTexture = Content.Load<Texture2D>("protagonistBodyAnimations");
            playerTexture  = Content.Load <Texture2D>("dreamManAnimations.png");
            debugSquare    = Content.Load <Texture2D>("debugSquare");
            arielBlackFont = Content.Load <SpriteFont>("SpriteFont1");

            device       = graphics.GraphicsDevice;
            spriteBatch  = new SpriteBatch(GraphicsDevice);
            origin.X     = graphics.PreferredBackBufferWidth / 2;
            origin.Y     = graphics.PreferredBackBufferHeight / 2;
            inputHandler = new InputHandler(origin);
            random       = new Random();

            tileRect = new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            cam      = new Camera(spriteBatch, tileRect, debugSquare);
            //actors = new List<Actor>();
            aiController      = new AIController();
            actorController   = new ActorController();
            physicsController = new PhysicsController();
            worldManager      = new WorldManager(random);
            worldManager.initWorldConfig(Content, "content/Worlds.xml");
            worldManager.initStartingWorld();
            soundManager = new SoundManager();
            soundManager.initSoundConfig(Content, "content/sfx/Sounds.xml");
            actorManager = new ActorManager();
            actorManager.initActorConfig(Content, "content/Actors.xml");
            actorManager.spawnActors(worldManager.curWorld.getSpawns());
        }
Esempio n. 7
0
    protected virtual void OnCollisionStay2D(Collision2D collision)
    {
        if (!Common.FUNC.IsStageTag(collision.gameObject.tag))
        {
            return;
        }

        foreach (ContactPoint2D contact in collision.contacts)
        {
            Vector2 p = contact.point - Common.FUNC.ParseVector2(myTran.position);
            if ((p.x > 0 && myVelocity.x > 0) || (p.x < 0 && myVelocity.x < 0))
            {
                //Unitの前方で衝突
                PhysicsController phyCtrl = collision.gameObject.GetComponent <PhysicsController>();
                if (phyCtrl != null && strength > 0 && phyCtrl.IsPlayer() != IsPlayer())
                {
                    float stageStrength = phyCtrl.GetStrength();
                    phyCtrl.Scrape(strength);
                    strength -= stageStrength;
                }
                if (strength <= 0)
                {
                    strength = 0;
                    StartCoroutine(Stack(1.5f));
                }
            }
            FlickFromStage(p);
        }
    }
        /*
         * Textures found at:
         * http://www.solarsystemscope.com/nexus/textures/planet_textures/
         */
        public RenderWindow(int width, int height, OpenTK.Graphics.GraphicsMode mode, string title) : base(width, height, mode, title)
        {
            physController  = new PhysicsController();
            camController   = new CameraController(new double[] { 0, 0.0f, -10000000 });//new double[] { -1000000.0f, 0.0f, -1000000.0f });
            graphController = new GraphicsController();
            graphController.ReadObjFile("sphere.obj");
            graphController.ReadSkyObjFile("skybox.obj");

            int[] newTextureIds = new int[8];
            GL.GenTextures(8, newTextureIds);
            newTextureIds[0] = graphController.LoadTexture("Textures/texture_sun.jpg");
            newTextureIds[1] = graphController.LoadTexture("Textures/texture_earth_clouds.jpg");
            newTextureIds[2] = graphController.LoadTexture("Textures/texture_mercury.jpg");
            newTextureIds[3] = graphController.LoadTexture("Textures/texture_venus_surface.jpg");
            newTextureIds[4] = graphController.LoadTexture("Textures/texture_mars.jpg");
            newTextureIds[5] = graphController.LoadTexture("Textures/texture_jupiter.jpg");
            newTextureIds[6] = graphController.LoadTexture("Textures/texture_saturn.jpg");
            newTextureIds[7] = graphController.LoadTexture("Textures/texture_moon.jpg");

            skyboxTextureId = graphController.LoadTexture("Textures/texture_skybox.jpg");
            textureIds      = newTextureIds;

            // Skybox
            double[] skyboxPos = new double[] { (float)-Math.Pow(10, 11) / 2, (float)-Math.Pow(10, 11) / 2, (float)-Math.Pow(10, 11) / 2 };
            skybox = new SimObject(skyboxPos, new PhysicsObject(), graphController.CreateSkyboxObj(1));
        }
Esempio n. 9
0
        //user-defined gravity
        public PhysicsManager(Game game, StatusType statusType, Vector3 gravity)
            : base(game, statusType)
        {
            physicSystem = new PhysicsSystem();

            //add cd/cr system
            physicSystem.CollisionSystem = new CollisionSystemSAP();

            //allows us to define the direction and magnitude of gravity - default is (0, -9.8f, 0)
            physicSystem.Gravity = gravity;

            //prevents bug where objects would show correct CDCR response when velocity == Vector3.Zero
            physicSystem.EnableFreezing = false;

            physicSystem.SolverType = PhysicsSystem.Solver.Normal;
            physicSystem.CollisionSystem.UseSweepTests = true;

            //affect accuracy and the overhead == time required
            physicSystem.NumCollisionIterations           = 8;
            physicSystem.NumContactIterations             = 8;
            physicSystem.NumPenetrationRelaxtionTimesteps = 12;

            #region SETTING_COLLISION_ACCURACY
            //affect accuracy of the collision detection
            physicSystem.AllowedPenetration  = 0.00025f;
            physicSystem.CollisionTollerance = 0.0005f;
            #endregion SETTING_COLLISION_ACCURACY

            physCont = new PhysicsController();
            physicSystem.AddController(physCont);
        }
Esempio n. 10
0
 void Awake()
 {
     player       = GetComponent <PhysicsController>();
     animator     = GetComponent <Animator>();
     mouseAnim    = GetComponent <CannonLookAtMouse>();
     pickupObject = GetComponent <PlayerPickupObject>();
 }
Esempio n. 11
0
 private void Initialize()
 {
     if (!character)
     {
         character = GameObject.Find("Character");
     }
     if (!boxCollider)
     {
         boxCollider = GetComponent <BoxCollider2D>();
     }
     if (SettingsIsNull)
     {
         settings = CreateInstance <RaycastSettings>();
     }
     if (InitializePlatformerController)
     {
         platformerController = GetComponent <PlatformerController>();
     }
     if (InitializeLayerMaskController)
     {
         layerMaskController = GetComponent <LayerMaskController>();
     }
     if (InitializePhysicsController)
     {
         physicsController = GetComponent <PhysicsController>();
     }
     if (DataIsNull)
     {
         Data = CreateInstance <RaycastData>();
     }
     Data.OnInitialize(ref boxCollider, ref character, settings);
 }
Esempio n. 12
0
 void Start()
 {
     input             = GetComponent <InputController>();
     physicsController = GetComponent <PhysicsController>();
     actionController  = GetComponent <ActionController>();
     state             = CharacterState.State.Idle;
 }
    //ステージに衝突
    protected override bool HitStage(GameObject obj)
    {
        base.HitStage(obj);

        //エフェクトの場合スルー
        if (tag == Common.CO.TAG_EFFECT)
        {
            return(false);
        }

        switch (obj.tag)
        {
        case Common.CO.TAG_OBJECT:
        case Common.CO.TAG_EQUIP_OBJECT:
            PhysicsController phyCtrl = obj.GetComponent <PhysicsController>();
            if (phyCtrl.IsPlayer() != IsPlayer())
            {
                float myStrength    = GetStrength();
                float enemyStrength = phyCtrl.GetStrength();
                phyCtrl.Scrape(myStrength);
                Scrape(enemyStrength);
            }
            break;

        default:
            Break();
            break;
        }

        return(true);
    }
Esempio n. 14
0
        // Initialises all variables and gets the physics component.
        public override void Initialise()
        {
            base.Initialise();

            physics   = GetComponent <PhysicsController>();
            dashAudio = GetComponent <AudioSource>();
            player    = transform.Find("Visuals");
            //dashIcon = player.Find("DashIcon").GetComponent<Renderer>();
            dashIcon = Camera.main.transform.GetChild(14).gameObject;
            dashIcon.SetActive(false);
            dashIcon2.SetActive(false);
            physics.Initialise();

            physics.onCollision     += onPlayerCollision;
            physics.onNearMiss      += OnPlayerNearMiss;
            physics.onRingHit       += OnPlayerRingHit;
            physics.onRelicHit      += OnPlayerRelicHit;
            physics.onPlayerCollect += OnPlayerCollect;

            comboCoroutine = ComboTimer();


            if (PlayerPrefs.HasKey("INVERT_Y"))
            {
                invertY = true;
            }
            else
            {
                invertY = false;
            }
        }
Esempio n. 15
0
    public IEnumerator FreezePlayers(Collider2D _collider)
    {
        PhysicsController _otherPhys     = _collider.gameObject.GetComponent <PhysicsController>();
        SpellCharges      _otherCharge   = _collider.gameObject.GetComponent <SpellCharges>();
        Animator          _otherAnimator = _collider.gameObject.GetComponent <Animator>();

        _otherPhys.PausePhysics(true);
        _otherCharge.SetFreezeTimer(true);
        _otherAnimator.speed = 0.0f;

        SFXManager.PlayOneShot(m_reference.GetComponent <AudioSource>(), SFXManager.GetHitEffect());

        yield return(new WaitForSeconds(0.2f));

        _collider.gameObject.GetComponent <PlayerFSM>().SetCurrentState(PlayerFSM.States.HIT, true);

        _otherPhys.ClearValues();
        _otherPhys.PausePhysics(false);
        _otherCharge.SetFreezeTimer(false);
        _otherAnimator.speed = 1.0f;



        ApplyForce(_collider);

        DestroyObject();
    }
Esempio n. 16
0
 void Start()
 {
     collider  = GetComponent <BoxCollider> ();
     direction = Vector2.up;
     direction.Normalize();
     phys = gameObject.GetComponent <PhysicsController> ();
 }
Esempio n. 17
0
        void Start()
        {
            //Subscribe for local events
            m_OnPauseStateChanged += UIManager.HandlePauseChangeState;
            m_OnScoreUpdate       += UIManager.UpdateScore;

            //Initialize AI
            m_AIManager = new AIManager(GameSettings.TimeBetweenShoots);

            //Initialize UI
            UIManager.OnPauseChange += ChangePause;
            UIManager.Init();

            //Initialize Input
            m_InputManager = new InputManager();

            //Set weight to the sun
            SunObject.Weight = GameSettings.SunWeight;

            //Initialize physics and add sun as attractor
            PhysicsController = new PhysicsController();
            PhysicsController.AddAttractor(SunObject);

            //Create player and enemies
            CreatePlayers();
        }
Esempio n. 18
0
	// Use this for initialization
	void Start () {
		pPhysics = GetComponent<PhysicsController>();
		moveAmount = new Vector2();
		defaultXScale = transform.localScale.x;
		StartCoroutine(computeState());
		startPosition = this.transform.position;
		map = GameObject.FindObjectOfType<Map>();
	}
Esempio n. 19
0
 private void Start()
 {
     accelModifier       = defaultAccelModifier;
     thisRigidybody      = GetComponent <Rigidbody>();
     psC                 = this.GetComponent <PhysicsController>();
     animationController = this.GetComponent <AnimationController>();
     gravityDirection    = defaultGravity;
 }
Esempio n. 20
0
 void Start()
 {
     phys        = gameObject.GetComponent <PhysicsController> ();
     velocity    = Vector2.zero;
     wall        = Vector2.zero;
     againstWall = false;
     canBounce   = true;
 }
Esempio n. 21
0
 // ====================================================
 public virtual void Start()
 {
     physicsController = GetComponent <PhysicsController>();
     physicsController.shouldUseSlopes = true;
     physicsController.SetCollisionLayers(LayerMask.GetMask(new string[] { "InvisibleWallLayer", "LevelLayer", "MoveBoxLayer" }),
                                          LayerMask.GetMask(new string[] { "InvisibleWallLayer", "LevelLayer", "MoveBoxLayer", "OneWayPlatformLayer" }));
     physicsController.Initialize();
 }
Esempio n. 22
0
 // Start is called before the first frame update
 void Start()
 {
     status   = GetComponent <StatusController>();
     physics  = GetComponent <PhysicsController>();
     rb       = transform.parent.GetComponent <Rigidbody2D>();
     animator = spriteHandle.GetComponent <Animator>();
     sprite   = spriteHandle.GetComponent <SpriteRenderer>();
 }
        internal GameController(ContentManager manager)
        {
            _Physics           = new PhysicsController();
            _TextureDictionary = new NeuralNetworkDictionary(manager); //Loads textures
            _AssetList         = new List <Asset>();

            ResetMap();
        }
Esempio n. 24
0
 void Start()
 {
     //Alternative to using a prefab
     //Debug.DrawLine(new Vector3(-5, 5, 0), new Vector3(5, 5, 0), Color.white, 2);
     physicsController = new PhysicsController();
     physicsController.setParticles(particles);
     physicsController.setElasticBodies(elasticBodies);
     physicsController.setHardBodies(hardBodies);
 }
Esempio n. 25
0
 // Use this for initialization
 void Start()
 {
     pPhysics      = GetComponent <PhysicsController>();
     moveAmount    = new Vector2();
     defaultXScale = transform.localScale.x;
     StartCoroutine(computeState());
     startPosition = this.transform.position;
     map           = GameObject.FindObjectOfType <Map>();
 }
Esempio n. 26
0
 internal GameController(CastleDungeonEscape main)
 {
     _GameWorld               = new List <MapObject>();
     _PhysicsController       = new PhysicsController();
     _UserInterface           = new InterfaceController();
     _Input                   = new InputController(this);
     _WorldCreationController = new WorldCreationController();
     _Saws = new List <MovingSaw>();
     _Main = main;
 }
Esempio n. 27
0
        public RigidBody(PhysicsController physics)
        {
            Physics = physics;
            Id      = Guid.NewGuid();

            Physics.GetSolver().onAdd += point =>
            {
                ContactAdd?.Invoke(point);
            };
        }
    // Use this for initialization
    void Start()
    {
        _animationHandler = GetComponent <PlayerAnimationHandler>();
        _animationHandler.Stay();

        _physicsController = GetComponent <PhysicsController>();

        _isPlayerInStartPointOfAnyMovableObject = false;
        _objectToMove = null;
    }
Esempio n. 29
0
    private void Awake()
    {
        startingPos = transform.position;

        LoopManager.StartReplay += StartReplay;
        LoopManager.ResetReplay += Reset;

        cannon         = GetComponent <CannonLookAtMouse>();
        physController = GetComponent <PhysicsController>();
    }
Esempio n. 30
0
    protected override void Move(Vector2 delta)
    {
        if (!PlayerController.playing)
        {
            return;
        }

        delta = direction * bulletSpeed * Time.deltaTime;
        float distance = delta.magnitude;

        if (distance > deadZone)
        {
            int count = rb.Cast(delta, contactFilter, hitBuffer, distance + padding);

            hitBufferList.Clear();
            for (int i = 0; i < count; i++)
            {
                hitBufferList.Add(hitBuffer[i]);
            }

            for (int i = 0; i < hitBufferList.Count; i++)
            {
                PhysicsController pc = hitBufferList[i].transform.GetComponent <PhysicsController>();
                if (pc != null)
                {
                    pc.hit(gameObject);
                }

                Vector2 currNormal = hitBufferList[i].normal;

                if (currNormal.y > minGroundNormalY)
                {
                    grounded = true;

                    if (delta.y != 0)
                    {
                        groundNormal = currNormal;
                        currNormal.x = 0;
                    }
                }

                float dotProduct = Vector2.Dot(velocity, currNormal);

                if (dotProduct < 0)
                {
                    velocity -= dotProduct * currNormal;
                }

                float modDistance = hitBufferList[i].distance - padding;
                distance = modDistance < distance ? modDistance : distance;
            }
        }

        rb.position += delta.normalized * distance;
    }
Esempio n. 31
0
 public HipsterEngine(float width, float height)
 {
     Physics        = new PhysicsController(this);
     Surface        = new Surface();
     Surface.Width  = width;
     Surface.Height = height;
     Particles      = new ParticlesController();
     Screens        = new ScreenController(this);
     DeltaTime      = new DeltaTime();
     Files          = new Files.Files();
 }