// Start is called before the first frame update
 void Start()
 {
     animator       = GetComponent <Animator>();
     player         = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerStats>();
     worldMover     = GameObject.FindGameObjectWithTag("WorldSpawner").GetComponent <WorldMover>();
     attackBehavior = GetComponent <EnemyAttackBehavior>();
 }
예제 #2
0
        void Awake()
        {
            wm = GameObject.FindObjectOfType <WorldMover>();

            uConstruct.BaseBuildingGroup.OnBuildingGroupCreatedEvent += (uConstruct.BaseBuildingGroup group) =>
            {
                group.gameObject.AddComponent <WorldStreamerGroupHandler>();

                if (wm != null)
                {
                    group.gameObject.AddComponent <ObjectToMove>();
                }
            };

            if (wm != null)
            {
                uConstruct.Core.Saving.BuildingSaveData.OnBuildingSavingEvent += (uConstruct.Core.Saving.BuildingSaveData data) =>
                {
                    data.pos -= wm.currentMove;
                };

                BaseBuilding.OnNetworkInstanceLoadedEvent += (BaseBuilding building) =>
                {
                    building.transform.position += wm.currentMove;
                };

                BaseBuilding.OnNetworkInstancePackedEvent += (BaseBuilding building) =>
                {
                    building.transform.position -= wm.currentMove;
                };
            }
        }
예제 #3
0
    void Start()
    {
        laneMovementDirection = Vector3.zero;
        currentLane           = 1;
        slideFromAir          = false;
        capsuleCollider       = this.gameObject.GetComponent <CapsuleCollider>();
        plot       = new TouchPlot();
        worldMover = GameObject.Find("WorldMover").GetComponent <WorldMover>();
        animator   = GetComponent <Animator>();

        Func <int, int, float> calcDistanceBetweenLane = (l1, l2) => Mathf.Abs(
            LaneOriginPoints.transform.GetChild(l2).transform.position.x -
            LaneOriginPoints.transform.GetChild(l1).transform.position.x
            );

        for (int i = 1; i < LaneOriginPoints.transform.childCount; i++)
        {
            if (i < 2)
            {
                distanceBetweenEachLane = calcDistanceBetweenLane(i - 1, i);
            }
            else if (Debug.isDebugBuild)
            {
                Debug.Assert(calcDistanceBetweenLane(i - 1, i) == distanceBetweenEachLane, "The distance between lanes must consistent");
            }
        }
    }
예제 #4
0
 // Use this for initialization
 void Start()
 {
     worldMoverFinder    = GameObject.Find("Road");
     anim                = GetComponent <Animator> ();
     worldMoverReference = worldMoverFinder.GetComponent <WorldMover> ();
     speed               = 0;
     speedScaler         = 50.0f;
 }
예제 #5
0
 void Start()
 {
     _mv            = GameObject.Find("WorldMover").GetComponent <WorldMover>();
     alive          = true;
     score          = 0;
     highScore.text = "High Score: " + PlayerPrefs.GetInt("highScore");
     updateText();
     butt = GameObject.Find("EGM");
     butt.SetActive(false);
 }
예제 #6
0
 private void Awake()
 {
     isGrounded  = false;
     startingPos = transform.position;
     rb          = GetComponent <Rigidbody>();
     if (gameCon != null)
     {
         gameScript = gameCon.GetComponent <WorldMover>();
     }
 }
예제 #7
0
        void Start()
        {
            wm = GameObject.FindObjectOfType <WorldMover>();
            bg = GetComponent <BaseBuildingGroup>();

            if (wm != null)
            {
                transform.position -= wm.currentMove;
            }
        }
예제 #8
0
    public void Start()
    {
        var player = GameObject.Find("Player");

        _aMa        = GameObject.Find("AudioManager").GetComponent <AudioManager>();
        _chCam      = Camera.main.GetComponent <ChappersCam>();
        _worldMover = GameObject.Find("Road").GetComponent <WorldMover>();
        _anim       = player.GetComponent <AnimHelper>();
        _spin       = player.GetComponentInChildren <DonutSpin>();
        _donut      = player.GetComponent <Donut>();
    }
예제 #9
0
    void Start()
    {
        WobbleAmplitude = WobbleAmplitude / 100f;

        //Initiate realpos with current position.
        _realPos = transform.position;

        //Grab the world bender so we can retrieve variables from it during warping. Allows for run-time editing of the
        //world bender's variable.
        _wbs        = GameObject.Find("Bender").GetComponent <WorldBender>();
        _worldMover = GameObject.Find("Road").GetComponent <WorldMover>();
    }
예제 #10
0
    void Start()
    {
        if (worldMover == null)
        {
            GameObject[] streamerGO = GameObject.FindGameObjectsWithTag(Streamer.STREAMERTAG);
            foreach (var item in streamerGO)
            {
                WorldMover mover = item.GetComponent <Streamer> ().worldMover;
                if (mover != null)
                {
                    worldMover = mover;
                }
            }
        }

        worldMover.AddObjectToMove(this);
    }
예제 #11
0
    void Start()
    {
        Time.timeScale = 1;
        pauseObjects   = GameObject.FindGameObjectsWithTag("Pause");
        alive          = true;
        godMode        = false;
        hidePause();
        worldMover       = GameObject.Find("WorldMover").GetComponent <WorldMover>();
        immortalityTimer = 3.0f;

        foreach (Upgrades.Upgrade t in ups.CurrentUpgrades())
        {
            if (t.IsMyName("godmode_timer"))
            {
                immortalityTimer += t.Level();
            }
        }
    }
예제 #12
0
 // Use this for initialization
 void Start()
 {
     player            = GetComponent <CharacterController>();
     col               = GetComponent <CapsuleCollider>();
     anim              = GetComponent <Animator>();
     plot              = new TouchPlot();
     gravity           = 37.0f;
     jumpforce         = 20.0f;
     desiredLane       = 0;
     speed             = 80f;
     verticalVelocity  = 0.0f;
     zedOrigin         = gameObject.transform.position.z;
     slideFromAir      = false;
     isSliding         = false;
     currentLane       = desiredLane;
     closeEnoughToLane = 0.05f;
     player.stepOffset = 0.3f;
     player.skinWidth  = player.radius * 0.1f;
     player.slopeLimit = 45;
     WorldMoverref     = FindObjectOfType <WorldMover>();
 }
예제 #13
0
 void OnWorldMoved(WorldMover _, Vector3 moveVector)
 {
     transform.position = transform.position - moveVector;
 }
예제 #14
0
파일: Donut.cs 프로젝트: Jibzi/Donut-Roll
    void Start()
    {
        //Initialise the score and UI to display it.
        Score     = 0;
        _scoreHUD = GameObject.Find("HUDCanvas").GetComponentInChildren <TextMeshProUGUI>();

        //Grab the AnimHelper, adds some functionality to calling animations.
        _animHelper = this.GetComponent <AnimHelper>();

        //Grab world mover
        _worldMover = GameObject.Find("Road").GetComponent <WorldMover>();

        //Initialise the left and right constrains, or "walls".
        _leftConstraint  = -5f;
        _rightConstraint = 5f;

        //Communicate to the "ChappersCam" that we want that script enabled.
        Camera.main.GetComponent <ChappersCam>().RunCamera = true;

        //Initialise IsJumping.
        IsJumping = false;

        //Initialise IsDead.
        IsDead = false;


        //Turn back all ye who do not wish a painful death - Will

        //Initialise Input handler
        inh = GameObject.Find("Player").AddComponent <InputHandler>();

        //Track Keys
        inh.TrackInput(KeyCode.Space, InputType.Button);
        inh.TrackInput(KeyCode.A, InputType.Button);
        inh.TrackInput(KeyCode.D, InputType.Button);
        inh.TrackInput(KeyCode.LeftArrow, InputType.Button);
        inh.TrackInput(KeyCode.RightArrow, InputType.Button);

        /*//////////////////////////////
        *  ///       Define Events      ///
        *  //////////////////////////////*/

        //Move Left
        inh.AddEvent(KeyCode.LeftArrow, InputEventType.Down, delegate(InputData inp)
        {
            _moveDirection = -1f;
            if (!IsDead)
            {
                _animHelper.Donut_BeginMoveLeft_Start(0f);
            }
        });
        inh.AddEvent(KeyCode.LeftArrow, InputEventType.Up, delegate(InputData inp)
        {
            if (_moveDirection == -1f)
            {
                _moveDirection = 0f;
            }
        });

        inh.AddEvent(KeyCode.A, InputEventType.Down, delegate(InputData inp)
        {
            _moveDirection = -1f;
            if (!IsDead)
            {
                _animHelper.Donut_BeginMoveLeft_Start(0f);
            }
        });
        inh.AddEvent(KeyCode.A, InputEventType.Up, delegate(InputData inp)
        {
            if (_moveDirection == -1f)
            {
                _moveDirection = 0f;
            }
        });

        //Move Right
        inh.AddEvent(KeyCode.RightArrow, InputEventType.Down, delegate(InputData inp)
        {
            _moveDirection = 1f;
            if (!IsDead)
            {
                _animHelper.Donut_BeginMoveRight_Start(0f);
            }
        });
        inh.AddEvent(KeyCode.RightArrow, InputEventType.Up, delegate(InputData inp)
        {
            if (_moveDirection == 1f)
            {
                _moveDirection = 0f;
            }
        });

        inh.AddEvent(KeyCode.D, InputEventType.Down, delegate(InputData inp)
        {
            _moveDirection = 1f;
            if (!IsDead)
            {
                _animHelper.Donut_BeginMoveRight_Start(0f);
            }
        });
        inh.AddEvent(KeyCode.D, InputEventType.Up, delegate(InputData inp)
        {
            if (_moveDirection == 1f)
            {
                _moveDirection = 0f;
            }
        });


        //Jump
        inh.AddEvent(KeyCode.Space, InputEventType.Down, delegate(InputData inp)
        {
            if (!IsJumping && !IsDead)
            {
                _animHelper.Donut_Jump_Start(0f);
            }
        });
    }
예제 #15
0
 // Use this for initialization
 void Start()
 {
     _worldMover = GameObject.Find("Road").GetComponent <WorldMover>();
 }
예제 #16
0
 public void Inject(WorldMover worldMover, WorldBuilder worldBuilder, GameObjectPool worldColumnPool)
 {
     _worldMover      = worldMover;
     _worldBuilder    = worldBuilder;
     _worldColumnPool = worldColumnPool;
 }
예제 #17
0
 // Use this for initialization
 void Start()
 {
     _populateRoad = gameObject.GetComponentInParent <PopulateRoad>();
     _worldMover   = gameObject.GetComponentInParent <WorldMover>();
 }
 public void Inject(WorldMover worldMover)
 {
     _worldMover = worldMover;
 }