Inheritance: MonoBehaviour
Exemple #1
0
 void Start()
 {
     player = FindObjectOfType <Player>();
     Gravity.SetPlanets(planets);
     player.active  = false;
     Time.timeScale = 1;
 }
Exemple #2
0
 private void Start()
 {
     gravity = GetComponent <Gravity>();
     SetPosition(transform.position);
     ResetForce();
     InvertMass = 1 / mass;
 }
 // Use this for initialization
 void Start()
 {
     _animator = GetComponent<Animator>();
     _gravity = GetComponent<Gravity>();
     _playerMovement = GetComponent<PlayerMovement>();
     _jump = GetComponent<Jump>();
 }
        void OnClick(Cursor.ClickType clickType, Rigidbody2D r)
        {
            if (!Achievements.achievementDic["World"].isDone)
            {
                return;
            }

            if (clickType == Cursor.ClickType.Sky)
            {
                Vector2    spawnPos     = Cursor.Instance.CursorPosition;
                GameObject newCharacter = Instantiate(_characterPrefab, spawnPos, Gravity.GetUpRotationAt(spawnPos), null);
                Instantiate(_starEffect, spawnPos, Quaternion.identity, null);
                characterSpawnedCount++;
                Human h = newCharacter.GetComponent <Human>();

                if (characterSpawnedCount >= firstWomanAt && !Achievements.achievementDic["Women"].isDone)
                {
                    h.ForceWoman();
                }

                else if (characterSpawnedCount >= firstWhiteAt && !Achievements.achievementDic["Race"].isDone)
                {
                    h.ForceWhite();
                }

                else if (Gravity.DistanceFromCenter(spawnPos) > 9)
                {
                    Achievements.AlienCreated();
                    h.SetRace(Human.Race.Alien);
                }

                Achievements.CharacterSpawned(h.sex, h.race);
            }
        }
Exemple #5
0
 protected int GetBitGravity(Gravity[] gravity)
 {
     int bit = 0;
     foreach (int flag in gravity) {
         bit |= flag;
     }
     return bit;
 }
Exemple #6
0
 // Use this for initialization
 void Start()
 {
     m_isJumping = false;
     m_physic    = gameObject.GetComponent <Rigidbody2D> ();
     m_direction = 0;        // start
     m_gravity   = gameObject.GetComponent <Gravity>();
     m_transform = gameObject.GetComponent <Transform> ();
 }
Exemple #7
0
 public void Init(Gravity g, bool fromCamera)
 {
     if (fromCamera)
     {
         source.Play();
     }
     gravity = g;
 }
    public void NewPlanetController(Gravity g, string name)
    {
        GameObject pc = Instantiate(PlanetControllerPrefab);

        pc.GetComponent <UIControllerSetup>().setup(g, name);
        pc.transform.SetParent(Content.gameObject.transform, false);
        planetControllers.Add(g, pc);
    }
Exemple #9
0
 // Use this for initialization
 void Start()
 {
     Gravity2   = GameObject.Find("Main Camera");
     gravity2   = Gravity2.GetComponent <Gravity>();
     velocity_y = jumppower;
     Player     = GameObject.Find("Player");
     Stairs     = GameObject.Find("Stairs");
 }
 public LayoutComponent()
 {
     Orientation = Orientation.Horizontal;
     Gravity     = Gravity.None;
     Spacing     = 2;
     Width       = GraphicsManager.Instance.VirtualWidth;
     Height      = GraphicsManager.Instance.VirtualHeight;
 }
Exemple #11
0
        public OneUp(IFactory spriteFactory, Point positionInGame) : base(spriteFactory, positionInGame, new Vector2())
        {
            this.sprite    = this.spriteFactory.CreateProduct(ItemTypes.OneUp);
            this.itemState = new ItemHiddenState(this);
            this.gravity   = new Gravity(this);

            this.hitboxOffset = -1;
        }
Exemple #12
0
 private void BodiesApplyGravity(IEnumerable <Body> allBodies, Gravity gravity)
 {
     foreach (var body in allBodies.Where(x => !(x.Static || x.Sleep)))
     {
         body.Force.X += body.Mass * gravity.Direction.X * gravity.Scaling;
         body.Force.Y += body.Mass * gravity.Direction.Y * gravity.Scaling;
     }
 }
    private Vector2 forwardDir; //specifies which direction the player is facing

    void Start()
    {
        body             = GetComponent <Rigidbody2D>();
        grav             = GetComponent <Gravity>();
        mySpriteRenderer = GetComponentInChildren <SpriteRenderer>();
        lastTimeStamp    = Time.time;
        forwardDir       = new Vector2(1, 0);
    }
 private static Level GetLevel(string name, Vector target, Gravity gravity)
 {
     return(new Level(
                name,
                new Rocket(location, Vector.Zero, -0.5 * Math.PI),
                target,
                gravity, standardPhysics));
 }
 protected override void Init()
 {
     base.Init();
     stats              = GetComponent <CharacterStats>();
     gravity            = GetComponent <Gravity>();
     fallLayerMask      = layerMask + LayerMask.GetMask("Bridge");
     stats.DeathAction += TurnOff;
 }
Exemple #16
0
    void Awake()
    {
        rigidbody = GetComponent <Rigidbody>();
        gravity   = GetComponent <Gravity>();
        mover     = GetComponent <Mover>();

        mover.MoverFinished += OnMoverFinished;
    }
Exemple #17
0
 // Use this for initialization
 void Start()
 {
     Player     = GameObject.Find("Player");
     Block      = GameObject.Find("Block");
     hpdisplay  = Player.GetComponent <HPDisplay> ();
     MainCamera = GameObject.Find("Main Camera");
     gravity    = MainCamera.GetComponent <Gravity> ();
 }
    public UNA_Segment (int segmentNumber)
    {
        this.segmentNumber = segmentNumber;

        pointsCollected = 0;
        timeElapsed = 0;
        gravitySetting = Gravity.Earth;
    }
    // Use this for initialization
    void Start()
    {
        _launch         = GetComponent <DeterioratingVelocity>();
        _gravity        = GetComponent <Gravity>();
        _randomVelocity = GetComponent <RandomSideVelocity>();

        _sideVelocity = _randomVelocity.getRandomVelocity();
    }
 public void DestroyBody(Gravity g)
 {
     physObjects.Remove(g);
     Destroy(g.gameObject.transform.parent.gameObject);
     Destroy(planetControllers[g]);
     planetControllers.Remove(g);
     --ObjectCounter;
 }
Exemple #21
0
 public CompanionCube(IFactory spriteFactory, Point positionInGame) : base(spriteFactory, positionInGame, new Vector2())
 {
     this.hitboxOffset     = 0;
     this.originalPosition = positionInGame;
     this.sprite           = spriteFactory.CreateProduct(BlockTypes.CompanionCube);
     Gravity = new Gravity(this);
     cubes.Add(this);
 }
Exemple #22
0
    void Awake()
    {
        gravity = GetComponent <Gravity>();
        number  = StarsManager.GetNumber();

        Init();
        oldPower = starConfig.power;
    }
Exemple #23
0
 public void Unregister(Gravity mass)
 {
     for (int i = 0; i < masses.Length; i++)
     {
         masses[i] = null;
         rbs[i]    = null;
     }
 }
    // Use this for initialization
    void Start()
    {
        gravity = GameObject.Find("World").GetComponent <Gravity>();
        Rigidbody rb = GetComponent <Rigidbody> ();

        rb.useGravity     = false;
        rb.freezeRotation = true;
    }
Exemple #25
0
        public void ShortAlert(string message)
        {
            // Toast.MakeText(Android.App.Application.Context, message, ToastLength.Short).Show();
            Toast f = Toast.MakeText(Android.App.Application.Context, message, ToastLength.Short);

            f.SetGravity(Gravity.GetAbsoluteGravity(GravityFlags.Center, GravityFlags.Center), 0, 0);
            f.Show();
        }
Exemple #26
0
 public Sword() : base(null, new Point(), new Vector2())
 {
     this.gravity = new Gravity(this);
     this.gravity.ChangeGravityIntensity(1.0f);
     this.SpriteFactory = EffectsFactory.GetInstance();
     this.SwordState    = new ReadyToSwingState(this);
     this.hitboxOffset  = 0;
 }
Exemple #27
0
 void Start()
 {
     actions          = GetComponent <PlayerActions>();
     gravity          = GetComponent <Gravity>();
     lookSens         = lookSensitivityBase;
     gravity.inSphere = false;
     StartCoroutine(AddPlayer());
 }
Exemple #28
0
 public void Initialize(Map map, Vector3Int gridPosition)
 {
     this.map                = map;
     this.gridPosition       = gridPosition;
     this.transform.position = map.basePosition + map.scaleFactor * gridPosition;
     isSliding               = false;
     gravity = map.tetrominoGravity;
 }
Exemple #29
0
        private float CalcForceInDirection(Base6Directions.Direction direction)
        {
            float force = 0;

            using (lock_thrustersInDirection.AcquireSharedUsing())
                foreach (MyThrust thruster in m_thrustersInDirection[(int)direction])
                {
                    if (!thruster.Closed && thruster.IsWorking)
                    {
                        force += GetThrusterMaxForce(thruster);
                    }
                }

            m_totalThrustForce[(int)direction] = force;

            if (direction == m_primaryForce.Direction)
            {
                //Log.DebugLog("updating primary force, direction: " + direction + ", force: " + force, "CalcForceInDirection()");
                m_primaryForce.Force = force;
            }
            else if (force > m_primaryForce.Force * 1.1f)
            {
                Log.DebugLog("stronger than primary force, direction: " + direction + ", force: " + force + ", acceleration: " + force / myGrid.Physics.Mass + ", primary: " + m_primaryForce, Logger.severity.DEBUG);
                m_secondaryForce         = m_primaryForce;
                m_primaryForce.Direction = direction;
                m_primaryForce.Force     = force;

                if (m_secondaryForce.Direction == Base6Directions.GetFlippedDirection(m_primaryForce.Direction))
                {
                    m_secondaryForce = new ForceInDirection()
                    {
                        Direction = Base6Directions.GetPerpendicular(m_primaryForce.Direction)
                    }
                }
                ;

                Log.DebugLog("secondary: " + m_secondaryForce);

                Standard.SetMatrixOrientation(m_primaryForce.Direction, m_secondaryForce.Direction);
                Gravity.SetMatrixOrientation(m_secondaryForce.Direction, m_primaryForce.Direction);
            }
            else if (direction == m_secondaryForce.Direction)
            {
                //Log.DebugLog("updating secondary force, direction: " + direction + ", force: " + force, "CalcForceInDirection()");
                m_secondaryForce.Force = force;
            }
            else if (force > m_secondaryForce.Force * 1.1f && direction != Base6Directions.GetFlippedDirection(m_primaryForce.Direction))
            {
                Log.DebugLog("stronger than secondary force, direction: " + direction + ", force: " + force + ", acceleration: " + force / myGrid.Physics.Mass + ", secondary: " + m_secondaryForce, Logger.severity.DEBUG);
                m_secondaryForce.Direction = direction;
                m_secondaryForce.Force     = force;
                Standard.SetMatrixOrientation(m_primaryForce.Direction, m_secondaryForce.Direction);
                Gravity.SetMatrixOrientation(m_secondaryForce.Direction, m_primaryForce.Direction);
            }

            //Log.DebugLog("direction: " + direction + "(" + (int)direction + ")" + ", force: " + force);
            return(force);
        }
Exemple #30
0
        public void BuildEntity(Entity entity, params object[] args)
        {
            string       enemyResourceFile = args[0] as string;
            string       dataFile          = "\\Enemies\\" + enemyResourceFile + ".json";
            CreatureData data = _dataManager.Load <CreatureData>(dataFile);

            Sprite sprite = _componentFactory.Create <Sprite>();

            sprite.Texture = _contentManager.Load <Texture2D>(".\\Graphics\\" + _fileSystem.Path.ChangeExtension(data.TextureFile, null));
            foreach (Animation animation in data.Animations)
            {
                sprite.Animations.Add(animation.Name, animation);
                if (animation.IsDefaultAnimation)
                {
                    sprite.SetCurrentAnimation(animation.Name);
                }
            }

            entity.AddComponent(sprite);
            entity.AddComponent(_componentFactory.Create <Health>());
            Position position = _componentFactory.Create <Position>();

            position.X = (int?)args[1] ?? 0;
            position.Y = (int?)args[2] ?? 0;
            entity.AddComponent(position);
            entity.AddComponent(_componentFactory.Create <Renderable>());
            entity.AddComponent(_componentFactory.Create <Velocity>());
            entity.AddComponent(_componentFactory.Create <Hostile>());
            entity.AddComponent(_componentFactory.Create <LocalData>());

            Nameable nameable = _componentFactory.Create <Nameable>();

            nameable.Name = data.Name;
            entity.AddComponent(nameable);

            Script script = _componentFactory.Create <Script>();

            script.FilePath = data.Script;
            entity.AddComponent(script);

            CollisionBox box = _componentFactory.Create <CollisionBox>();

            box.Width   = data.CollisionWidth;
            box.Height  = data.CollisionHeight;
            box.OffsetX = data.CollisionOffsetX;
            box.OffsetY = data.CollisionOffsetY;
            entity.AddComponent(box);

            Heartbeat hb = _componentFactory.Create <Heartbeat>();

            hb.Interval = data.HeartbeatInterval;
            entity.AddComponent(hb);

            Gravity gravity = _componentFactory.Create <Gravity>();

            gravity.Speed = 4.0f;
            entity.AddComponent(gravity);
        }
Exemple #31
0
 private static Level InitLevel(string name     = "NoName", Rocket rocket = null, Vector target = null,
                                Gravity gravity = null, Physics physics   = null)
 {
     rocket  = rocket ?? defultRocket;
     target  = target ?? defaultTarget;
     gravity = gravity ?? ((size, l) => Vector.Zero);
     physics = physics ?? standardPhysics;
     return(new Level(name, rocket, target, gravity, physics));
 }
Exemple #32
0
 protected virtual void Init()
 {
     physic                = GetComponent <CharacterPhysic>();
     stats                 = GetComponent <CharacterStats>();
     gravity               = GetComponent <Gravity>();
     stats.DeathAction    += JumpStop;
     stats.DeathAction    += jumpDownReset;
     stats.onGroundAction += ChargeJump;
 }
 public CaptionFunction()
 {
     X = 0;
     Y = 0;
     Width = "90%";
     Height = "90%";
     Colour = "#ffffff";
     FontFamily = "Helvetica";
     PointSize = 12;
     Gravity = Gravity.CenterGrativty;
 }
Exemple #34
0
 void Start()
 {
     gravity = new Gravity (Application.dataPath+"/Resources/Dg01_cnt2.5x2.bytes");
     Input.location.Start();           //enable location settings
     Input.compass.enabled = true;
     locationStatus = LocationServiceStatus.Running;
     lon = 0; alt = 0; lat = 0;
     dlon = 0; dalt = 0; dlat = 0;
     gAn=gravity.GetGravity(lat,lon,alt);
     gAcc = gravity.GetAcceleration (gAn);
     startLocationService();               //begin GPS transmittion
 }
Exemple #35
0
    void Awake()
    {
        activator = GetComponentInChildren<Activator>();
        eye = GetComponentInChildren<Eye>();
        inventory = GetComponentInChildren<Inventory>();
        lastPositionKeeper = GetComponentInChildren<LastPositionKeeper>();
        head = GetComponentInChildren<Head>();
        cameraPlace = GetComponentInChildren<CameraPlace>();
        undo = GetComponentInChildren<Undo>();
        characterController = GetComponentInChildren<CharacterController>();
        rewind = GetComponentInChildren<Rewind>();
        slowmo = GetComponentInChildren<Slowmo>();
        gravity = GetComponentInChildren<Gravity>();

        all.Add(this);
    }
Exemple #36
0
		public static CGRect ApplyGravity(this CGRect bounds, CGSize size, Gravity g)
		{
			nfloat left;
			switch (g & Gravity.HorizontalMask)
			{
				default:
					left = bounds.Left;
					break;

				case Gravity.Right:
					left = bounds.Right - size.Width;
					break;

				case Gravity.CenterHorizontal:
					left = (bounds.Left + bounds.Right - size.Width)/2;
					break;
			}

			nfloat top;
			switch (g & Gravity.VerticalMask)
			{
				default:
					top = bounds.Top;
					break;

				case Gravity.Bottom:
					top = bounds.Bottom - size.Height;
					break;

				case Gravity.CenterVertical:
					top = (bounds.Top + bounds.Bottom - size.Height)/2;
					break;
			}

			return new CGRect(left, top, size.Width, size.Height);
		}
Exemple #37
0
    void Awake()
    {
        gravity = GetComponent<Gravity>();
        number = StarsManager.GetNumber();

        Init();
        oldPower = starConfig.power;
    }
Exemple #38
0
 public void Gravity(Gravity value)
 {
   IntPtr exception = IntPtr.Zero;
   #if ANYCPU
   if (NativeLibrary.Is64Bit)
   #endif
   #if WIN64 || ANYCPU
   NativeMethods.X64.DrawingWand_Gravity(Instance, (UIntPtr)value, out exception);
   #endif
   #if ANYCPU
   else
   #endif
   #if !WIN64 || ANYCPU
   NativeMethods.X86.DrawingWand_Gravity(Instance, (UIntPtr)value, out exception);
   #endif
   CheckException(exception);
 }
Exemple #39
0
 public void CompositeGravity(MagickImage image, Gravity gravity, CompositeOperator compose)
 {
   IntPtr exception = IntPtr.Zero;
   #if ANYCPU
   if (NativeLibrary.Is64Bit)
   #endif
   #if WIN64 || ANYCPU
   NativeMethods.X64.MagickImage_CompositeGravity(Instance, MagickImage.GetInstance(image), (UIntPtr)gravity, (UIntPtr)compose, out exception);
   #endif
   #if ANYCPU
   else
   #endif
   #if !WIN64 || ANYCPU
   NativeMethods.X86.MagickImage_CompositeGravity(Instance, MagickImage.GetInstance(image), (UIntPtr)gravity, (UIntPtr)compose, out exception);
   #endif
   CheckException(exception);
 }
 public void SetGravity(Gravity value)
 {
   #if ANYCPU
   if (NativeLibrary.Is64Bit)
   #endif
   #if WIN64 || ANYCPU
   NativeMethods.X64.MontageSettings_SetGravity(Instance, (UIntPtr)value);
   #endif
   #if ANYCPU
   else
   #endif
   #if !WIN64 || ANYCPU
   NativeMethods.X86.MontageSettings_SetGravity(Instance, (UIntPtr)value);
   #endif
 }
 void Start()
 {
     this.NearestPlanet = InterplanetaryObject.GetNearestPlanet(this.transform.position);
 }
	    public PadResizeToFitFunction()
        {
            Colour = "#ffffff";
            Gravity = Gravity.CenterGrativty;
        }
		public AttrGravity (Gravity gravity) : this (pango_attr_gravity_new ((int) gravity)) {}
Exemple #44
0
 public void Gravity(Gravity value)
 {
   _NativeInstance.Gravity(value);
 }
 void Start()
 {
     g = GameObject.FindGameObjectWithTag("GameController").GetComponent<Gravity>();
     rb = GetComponent<Rigidbody2D>();
     g.AddBody(rb);
 }
		public DrawableGravity(Gravity gravity)
			: base(AssemblyHelper.CreateInstance(Types.DrawableGravity, new Type[] {Types.Gravity}, gravity))
		{
		}
 public CropToSquareFunction()
 {
     Gravity = Gravity.CenterGrativty;
 }
Exemple #48
0
 public void AnnotateGravity(DrawingSettings settings, string text, Gravity gravity)
 {
   using (INativeInstance settingsNative = DrawingSettings.CreateInstance(settings))
   {
     using (INativeInstance textNative = UTF8Marshaler.CreateInstance(text))
     {
       IntPtr exception = IntPtr.Zero;
       #if ANYCPU
       if (NativeLibrary.Is64Bit)
       #endif
       #if WIN64 || ANYCPU
       NativeMethods.X64.MagickImage_AnnotateGravity(Instance, settingsNative.Instance, textNative.Instance, (UIntPtr)gravity, out exception);
       #endif
       #if ANYCPU
       else
       #endif
       #if !WIN64 || ANYCPU
       NativeMethods.X86.MagickImage_AnnotateGravity(Instance, settingsNative.Instance, textNative.Instance, (UIntPtr)gravity, out exception);
       #endif
       CheckException(exception);
     }
   }
 }
Exemple #49
0
 public CropFunction()
 {
     Gravity = Gravity.CenterGrativty;
 }
 // Use this for initialization
 void Start()
 {
     m_text = GetComponent<TextMesh> ();
     gravity = GameObject.FindObjectOfType<Gravity> ();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DrawableGravity"/> class.
 /// </summary>
 /// <param name="gravity">The gravity.</param>
 public DrawableGravity(Gravity gravity)
 {
   Gravity = gravity;
 }
 public override void OnGUI()
 {
     userInput = (Gravity)EditorGUILayout.EnumMaskField(label + ":", userInput);
 }
    void Start()
    {
        orbit = GetComponent<Orbital>();
        orbit.enabled = false;
        g = player.GetComponent<Gravity>();
        g.enabled = true;
        timer = tm;

        audio = gameObject.GetComponentInParent<AudioPlayer>();
    }
 public override void Refresh(AndroidManifest manifest)
 {
     if (!manifest.HasMetaData(metaDataName))
     {
         if (!defaulted)
         {
             defaulted = true;
             userInput = defaultValue;
         }
         return;
     }
     var value = manifest.GetMetaData(metaDataName);
     if (((int)userInput == 0) && string.IsNullOrEmpty(metaDataValue))
     {
         userInput = (Gravity)GravityConverter.FromInt(int.Parse(value));
     }
     metaDataValue = value;
 }
Exemple #55
0
 /// <summary>
 /// Creates a new DrawableGravity instance.
 /// </summary>
 /// <param name="gravity">The gravity.</param>
 public Drawables Gravity(Gravity gravity)
 {
   _Drawables.Add(new DrawableGravity(gravity));
   return this;
 }
Exemple #56
0
 public void Add(Gravity g)
 {
     worldObjects.Add(g);
 }
 void Start()
 {
     gravity = GameObject.FindObjectOfType<Gravity> ();
     introText = GameObject.FindObjectOfType<IntroText> ();
 }
Exemple #58
0
 public void Remove(Gravity g)
 {
     worldObjects.Remove(g);
 }
Exemple #59
0
 public void ExtentGravity(string geometry, Gravity gravity)
 {
   using (INativeInstance geometryNative = UTF8Marshaler.CreateInstance(geometry))
   {
     IntPtr exception = IntPtr.Zero;
     IntPtr result;
     #if ANYCPU
     if (NativeLibrary.Is64Bit)
     #endif
     #if WIN64 || ANYCPU
     result = NativeMethods.X64.MagickImage_ExtentGravity(Instance, geometryNative.Instance, (UIntPtr)gravity, out exception);
     #endif
     #if ANYCPU
     else
     #endif
     #if !WIN64 || ANYCPU
     result = NativeMethods.X86.MagickImage_ExtentGravity(Instance, geometryNative.Instance, (UIntPtr)gravity, out exception);
     #endif
     CheckException(exception, result);
     Instance = result;
   }
 }
Exemple #60
0
 void Start()
 {
     animController = GetComponent<Animator>();
     rigidbody = GetComponent<Rigidbody2D>();
     gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
     gravity = GetComponent<Gravity>();
     Spawn();
 }