Example #1
0
        private UICanvas BuildMainMenu()
        {
            UICanvas canvas = new UICanvas();

            canvas.Add(new UIButton("Versus KI", Color.White, Color.Yellow, 32, new Vector2(0f, -120f), true)
                       .OnClick((button, scene) => {
                Player.isHost        = true;
                Player.isMultiplayer = false;
                scene.manager.Load(PreparingScene.Id);
            }));


            canvas.Add(new UIButton("Host", Color.White, Color.Yellow, 32, new Vector2(0f, -20f), true)
                       .OnClick((button, scene) => {
                Player.isHost        = true;
                Player.isMultiplayer = true;
                scene.manager.Load(PreparingScene.Id);
            }));

            canvas.Add(new UIButton("Connect", Color.White, Color.Yellow, 32, new Vector2(0f, 80f), true)
                       .OnClick((button, scene) => {
                Player.isHost        = false;
                Player.isMultiplayer = true;
                scene.manager.Load(PreparingScene.Id);
            }));

            canvas.Add(new UIButton("Exit", Color.White, Color.Yellow, 32, new Vector2(0f, 180), true)
                       .OnClick((button, scene) => Application.Close()));

            return(canvas);
        }
Example #2
0
        public SampleScene(bool addExcludeRenderer = true, bool needsFullRenderSizeForUi = false)
        {
            _needsFullRenderSizeForUi = needsFullRenderSizeForUi;

            // setup one renderer in screen space for the UI and then (optionally) another renderer to render everything else
            if (needsFullRenderSizeForUi)
            {
                // dont actually add the renderer since we will manually call it later
                _screenSpaceRenderer = new ScreenSpaceRenderer(100, ScreenSpaceRenderLayer);
                _screenSpaceRenderer.ShouldDebugRender = false;
                FinalRenderDelegate = this;
            }
            else
            {
                AddRenderer(new ScreenSpaceRenderer(100, ScreenSpaceRenderLayer));
            }

            if (addExcludeRenderer)
            {
                AddRenderer(new RenderLayerExcludeRenderer(0, ScreenSpaceRenderLayer));
            }

            // create our canvas and put it on the screen space render layer
            Canvas = CreateEntity("ui").AddComponent(new UICanvas());
            Canvas.IsFullScreen = true;
            Canvas.RenderLayer  = ScreenSpaceRenderLayer;
            SetupSceneSelector();
        }
Example #3
0
 protected override UICanvas CreateUICanvas()
 {
     canvas = new UICanvas();
     canvas.isFullScreen = true;
     canvas.setRenderLayer(WorldController.SCREEN_SPACE_RENDER_LAYER);
     return(canvas);
 }
Example #4
0
        public SampleScene(bool addExcludeRenderer = true, bool needsFullRenderSizeForUI = false) : base()
        {
            // setup one renderer in screen space for the UI and then (optionally) another renderer to render everything else
            if (needsFullRenderSizeForUI)
            {
                // dont actually add the renderer since we will manually call it later
                _screenSpaceRenderer = new ScreenSpaceRenderer(100, SCREEN_SPACE_RENDER_LAYER);
                _screenSpaceRenderer.shouldDebugRender = false;
                finalRenderDelegate = this;
            }
            else
            {
                addRenderer(new ScreenSpaceRenderer(100, SCREEN_SPACE_RENDER_LAYER));
            }

            if (addExcludeRenderer)
            {
                addRenderer(new RenderLayerExcludeRenderer(0, SCREEN_SPACE_RENDER_LAYER));
            }

            // create our canvas and put it on the screen space render layer
            canvas = createEntity("ui").addComponent(new UICanvas());
            canvas.isFullScreen = true;
            canvas.renderLayer  = SCREEN_SPACE_RENDER_LAYER;
            setupSceneSelector();
        }
Example #5
0
        public override void initialize()
        {
            base.initialize();

            Core.debugRenderEnabled       = true;
            Transform.shouldRoundPosition = false;

            clearColor = Color.Black;

            canvas = createEntity("ui").addComponent(new UICanvas());
            canvas.isFullScreen = true;
            canvas.renderLayer  = 0;

            var table = canvas.stage.addElement(new Table());


            table.setFillParent(true).center();

            table.add("HerdBurglar");
            table.row().setPadTop(50);
            table.add("Press space to start..");


            addRenderer(new DefaultRenderer());
        }
Example #6
0
    // Use this for initialization
    void Start()
    {
        UICanvas UIcanvas = GameObject.FindGameObjectWithTag("UICanvas").GetComponent <UICanvas>();

        Tooltip = UIcanvas.Tooltip;
        GameObject Player = GameObject.FindGameObjectWithTag("Player");

        if (Player == null)
        {
            StructureSetting.instance.ActiveTrue();
            Player = GameObject.FindGameObjectWithTag("Player");
        }
        cd = Player.GetComponent <ChampionData>();

        if (spellkey == "D")
        {
            myspell         = cd.spell_D;
            myspellcooldown = cd.Cooldown_D;
        }
        else if (spellkey == "F")
        {
            myspell         = cd.spell_F;
            myspellcooldown = cd.Cooldown_F;
        }
        getname(myspell);
    }
Example #7
0
    // Use this for initialization
    void Start()
    {
        UICanvas UIcanvas = GameObject.FindGameObjectWithTag("UICanvas").GetComponent <UICanvas>();

        Tooltip     = UIcanvas.Tooltip;
        ItemTooltip = UIcanvas.ItemTooltip;
    }
Example #8
0
 public void Process(bool show, bool pick)
 {
     if (base.isActiveAndEnabled != show)
     {
         base.gameObject.SetActive(show);
     }
     if (allowPicking != pick)
     {
         allowPicking = pick;
         if (allowPicking)
         {
             MenuCameraEffects.SuspendEffects(suspend: true);
             mainCamera.SetReplacementShader(Shaders.instance.customizeUnlitShader, "RenderType");
             mainCamera.renderingPath = RenderingPath.Forward;
         }
         else
         {
             MenuCameraEffects.SuspendEffects(suspend: false);
             mainCamera.ResetReplacementShader();
             mainCamera.renderingPath = RenderingPath.UsePlayerSettings;
         }
     }
     if (show)
     {
         Vector2 anchoredPosition = UICanvas.ScreenPointToLocal(parentRect, Input.mousePosition);
         rect.anchoredPosition = anchoredPosition;
         if (allowPicking)
         {
             StartCoroutine(PickColor());
         }
         colorPreviewBox.color = color;
     }
 }
Example #9
0
    IEnumerator FlickeringText(string str, UICanvas canvs, float time)
    {
        GameObject go_new    = Instantiate(text);
        Text       text_show = go_new.GetComponent <Text>();

        go_new.transform.SetParent(canvs.cnvs.transform);
        text_show.rectTransform.localPosition = Vector3.zero;
        text_show.fontSize = 35;
        text_show.text     = str;
        bool plusminus = true;

        for (float i = 0; i < (time * 2); i++)
        {
            if (plusminus)
            {
                text_show.enabled = true;
                plusminus         = false;
                yield return(new WaitForSeconds(0.5f));
            }
            else
            {
                text_show.enabled = false;
                plusminus         = true;
                yield return(new WaitForSeconds(0.5f));
            }
        }
        Destroy(go_new);
    }
Example #10
0
    void Start()
    {
        mStats           = new Stats(1, 60, 12, 2, 0, new int[] { 20, 4, 2, 0 });
        mRigidBody       = GetComponent <Rigidbody> ();
        mAnimator        = GetComponent <Animator> ();
        mFacingDirection = Vector2.right;
        mDying           = false;

        mTarget = GameObject.Find("Player").transform;

        expGiven = 15;
        //expGiven = 15 - 2 * (GameObject.Find ("Player").GetComponent<Player> ().mStats.Level - mStats.Level);

        mFloorControllerRef      = FindObjectOfType <FloorController> ();
        mFloorBoundary           = new float[4];
        mSpriteRenderer          = gameObject.GetComponentInChildren <SpriteRenderer> ();
        mInitialOrderInLayer     = (int)(transform.position.y);
        floorBoundaryInitialized = false;

        AudioSource[] audioSources = GetComponents <AudioSource> ();
        normalHit = audioSources [0];
        strongHit = audioSources [1];
        knifeHit  = audioSources [2];

        uiCanvas = (UICanvas)GameObject.FindGameObjectWithTag("UICanvas").GetComponent <UICanvas> ();
    }
Example #11
0
 public void Process(bool show)
 {
     if (base.isActiveAndEnabled != show)
     {
         base.gameObject.SetActive(show);
     }
     if (show)
     {
         cursorMaterial.color = color;
         Material material       = cursorMaterial;
         Vector3  mousePosition  = Input.mousePosition;
         float    x              = mousePosition.x;
         Vector3  mousePosition2 = Input.mousePosition;
         material.SetVector("_PointPos", new Vector4(x, mousePosition2.y, 0f, 0f));
         cursorMaterial.SetVector("_ScreenSize", new Vector4(Screen.width, Screen.height, 0f, 0f));
         cursorMaterial.SetFloat("_PointSize", cursorKernel);
         cursorMaterial.SetFloat("_FalloffSize", cursorFalloff);
         float   d = (float)(2 * Screen.height) * (cursorFalloff + cursorKernel) + 2f;
         Vector2 anchoredPosition = UICanvas.ScreenPointToLocal(cursorParentRect, Input.mousePosition);
         Vector2 vector           = UICanvas.ScreenPointToLocal(cursorParentRect, Input.mousePosition + new Vector3(1f, 1f, 0f) * d);
         cursor.rectTransform.anchoredPosition = anchoredPosition;
         cursor.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, vector.x - anchoredPosition.x);
         cursor.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, vector.y - anchoredPosition.y);
     }
 }
    IEnumerator SwitchingUIToggle()
    {
        if (UIMenuActive == true)
        {
            GetComponentInParent <UnityStandardAssets.Characters.FirstPerson.FirstPersonController>().enabled = false;

            yield return(new WaitForSeconds(UITransitionTime));

            UICanvas.SetActive(true);
            MoveCam = false;
            UISelections.AddRange(UIMainMenu);
            foreach (Text obj  in UISelections)
            {
                obj.gameObject.SetActive(true);
            }
            UISelections[CurrentUIMenu].fontSize = 16;
        }

        else
        {
            UISelections[CurrentUIMenu].fontSize = 14;
            UISelections.Clear();
            UICanvas.SetActive(false);
            yield return(new WaitForSeconds(UITransitionTime));

            GetComponentInParent <UnityStandardAssets.Characters.FirstPerson.FirstPersonController>().enabled = true;
            MoveCam = false;
        }
    }
Example #13
0
    void Start()
    {
        UICanvas uiCanvas = GameObject.FindGameObjectWithTag("UICanvas").GetComponent <UICanvas>();

        tooltip = uiCanvas.tooltip;

        GameObject Player = GameObject.FindGameObjectWithTag("Player");

        if (Player == null)
        {
            StructureSetting.instance.ActiveTrue();
            Player = GameObject.FindGameObjectWithTag("Player");
        }

        myChampionData = Player.GetComponent <ChampionData>();

        if (spellkey == "D")
        {
            mySpellNum      = myChampionData.spell_D;
            mySpellCooldown = myChampionData.Cooldown_D;
        }
        else if (spellkey == "F")
        {
            mySpellNum      = myChampionData.spell_F;
            mySpellCooldown = myChampionData.Cooldown_F;
        }

        SetSpellNameDescription(mySpellNum);
    }
Example #14
0
 public void ClearUI()
 {
     foreach (GameObject UICanvas in Simulation.UICanvases)
     {
         UICanvas.SetActive(false);
     }
 }
Example #15
0
        public override void initialize()
        {
            base.initialize();

            setDesignResolution(800, 640, Scene.SceneResolutionPolicy.NoBorderPixelPerfect);
            clearColor = Color.Black;
            Screen.setSize(800, 640);


            var skin = Skin.createDefaultSkin();

            canvas = createEntity("ui").addComponent(new UICanvas());

            canvas.isFullScreen = true;
            canvas.renderLayer  = 999;

            loadingLBL = canvas.stage.addElement(new Label("Loading...", skin));
            loadingLBL.setFontColor(Color.White);
            loadingLBL.setFontScale(3);
            loadingLBL.setPosition(25, Screen.height - 40);

            loadingSchedule = Core.schedule(2, true, new Action <ITimer>(
                                                (ITimer timer) =>

                                                loadingTimer += 1
                                                ));
        }
Example #16
0
    void Start()
    {
        UICanvas uiCanvas = GameObject.FindGameObjectWithTag("UICanvas").GetComponent <UICanvas>();

        midTooltip  = uiCanvas.tooltip;
        itemTooltip = uiCanvas.itemTooltip;
    }
Example #17
0
    private Color ColorAtScreenPos(Vector2 mousePos)
    {
        Vector2 vector = UICanvas.ScreenPointToLocal(base.transform as RectTransform, mousePos);
        Color   pixel  = texture.GetPixel(Mathf.Clamp((int)vector.x, 0, 512), Mathf.Clamp((int)vector.y, 0, 512));

        isTransparent = (pixel.a < 0.5f);
        return(pixel);
    }
Example #18
0
    // Use this for initialization
    void Start()
    {
        UICanvas UIcanvas = GameObject.FindGameObjectWithTag("UICanvas").GetComponent <UICanvas>();

        Tooltip = UIcanvas.Tooltip;
        stat    = UIcanvas.Stat.GetComponent <UIStat>();
        skill   = UIcanvas.Skill.GetComponent <UISkill>();
    }
Example #19
0
        public HUD()
        {
            canvas = AddComponent(new UICanvas());
            canvas.IsFullScreen = true;
            canvas.RenderLayer  = (int)Utils.RenderLayer.UI;

            canvas.Stage.AddElement(new HealthBar());
        }
Example #20
0
 /// <summary>
 ///     Method used when creating an UIComponent.
 ///     It looks if the selected object has a RectTransform (and returns it as the parent).
 ///     If the selected object is null or does not have a RectTransform, it returns the MasterCanvas GameObject as the parent.
 /// </summary>
 /// <param name="selectedObject"> Selected object </param>
 protected static GameObject GetParent(GameObject selectedObject)
 {
     if (selectedObject == null)
     {
         return(UICanvas.GetMasterCanvas().gameObject);                                    //selected object is null -> returns the MasterCanvas GameObject
     }
     return(selectedObject.GetComponent <RectTransform>() != null ? selectedObject : UICanvas.GetMasterCanvas().gameObject);
 }
Example #21
0
 ///
 /// \brief Used for initialisation
 ///
 /// \return No return value
 ///
 /// \details Finds and sets the component variables
 ///
 void Start()
 {
     rectrans     = GetComponent <RectTransform>();
     rb2d         = GetComponent <Rigidbody2D>();
     bound        = new Bounds();
     bound.center = transform.position;
     bound.size   = new Vector3(UICanvas.getWidth() - rectrans.rect.width, UICanvas.getHeight() - rectrans.rect.height, 1);
 }
Example #22
0
    public void AttemptCreateAccount()
    {
        string user = txtUsername.text;
        string pass = txtPassword.text;

        UICanvas.Get().TurnOnDarkenator();
        DatabaseHandler.Get().CreateAccount(user, pass, CreateAccountCallback);
    }
Example #23
0
        public virtual void BruhUi()
        {
            UICanvas = CreateEntity("ui-canvas").AddComponent(new UICanvas());

            Table = UICanvas.Stage.AddElement(new Table());

            Table.SetFillParent(true).Top().PadLeft(10).PadTop(50);
        }
Example #24
0
        private void CreateEntities()
        {
            var tiledMap = content.Load <TiledMap>(_settings.MapTile);

            String[] tiledMapLayers = new[]
            {
                TiledImportCollisionLayers.BACK_WALLS, TiledImportCollisionLayers.SIDE_WALLS, TiledImportCollisionLayers.NET
            };
            int[] tiledMapPhysicsLayers = new[]
            {
                PhysicsLayers.BACK_WALLS, PhysicsLayers.SIDE_WALLS, PhysicsLayers.NET
            };
            var tiledMapComponent = new Handy.Components.TiledMapComponent(tiledMap, tiledMapLayers, tiledMapPhysicsLayers, true);
            var entity            = new Entity();

            entity.name = "Map";
            tiledMapComponent.renderLayer = RenderLayers.BACKGROUND;
            entity.addComponent(tiledMapComponent);
            addEntity(entity);

            var gameState = new GameState();

            gameState.StateEnum = GameStates.Ready;
            gameState.Players   = new Player.Player[_settings.NumPlayers];
            for (var i = 0; i < _settings.NumPlayers; i++)
            {
                var playerSettings = _settings.Players[i];
                var player         = new Player.Player(playerSettings);
                addEntity(player);
                gameState.Players[i] = player;
            }

            var ball = new Ball.Ball();

            addEntity(ball);
            gameState.Ball = ball;

            GameStateEntity      = new Entity();
            GameStateEntity.name = "Game";
            GameStateEntity.addComponent(new GameStateComponent(gameState));
            GameStateEntity.addComponent(new TimerComponent());
            GameStateEntity.addComponent(new HitStopComponent());
            var scoreboard = new UICanvas();

            scoreboard.name        = "scoreboard";
            scoreboard.renderLayer = RenderLayers.FOREGROUND;
            GameStateEntity.addComponent(scoreboard);
            addEntity(GameStateEntity);

            // add camera
            var cam         = new Camera();
            var cameraShake = new CameraShakeComponent();

            CameraEntity.addComponent(cam);
            CameraEntity.addComponent(cameraShake);
            CameraEntity.name = "Camera";
            addEntity(CameraEntity);
        }
Example #25
0
    // Use this for initialization
    void Awake()
    {
        if (instance == null)
            instance = this;
        else if (instance != this)
            Destroy (gameObject);

        DontDestroyOnLoad (gameObject);
    }
Example #26
0
    void PasswordChangeCallback(bool _success, DatabaseHandler.ErrorResult _error)
    {
        UICanvas.Get().TurnOffDarkenator();

        if (_success)
        {
            Close();
        }
    }
Example #27
0
    private void CreateAccountCallback(bool _success, DatabaseHandler.ErrorResult _message)
    {
        UICanvas.Get().TurnOffDarkenator();

        if (_success)
        {
            MasterManager.instance.PanelManager.ChangePanels(EGameScreens.GS_Login);
        }
    }
 public void HideActiveCanvas()
 {
     if (_currentCanvasActive != null)
     {
         HideCanvas(_currentCanvasActive.CanvasGroup);
         _currentCanvasActive.DisableCanvas();
         _currentCanvasActive = null;
     }
 }
 /// <summary>
 /// Changes out the current canvas for a new one
 /// </summary>
 /// <param name="canvas">The canvas we want to change to</param>
 public void ChangeCanvas(UICanvas canvas)
 {
     currentCanvas = canvas;
     if (canvas != null)
     {
         currentCanvas.Initialize();
         currentCanvas.LoadContent();
     }
 }
Example #30
0
 void addLayersFromBuffer(Stack <UICanvas> buffer)
 {
     while (buffer.Count > NONE_VALUE)
     {
         UICanvas currentCanvas = buffer.Pop();
         currentCanvas.setSortLayer(getNextSortLayer());
         canvasLayers.Push(currentCanvas);
     }
 }
Example #31
0
        public void SetupScene()
        {
            AddRenderer(new DefaultRenderer());
            UICanvas = CreateEntity("ui-canvas").AddComponent(new UICanvas());

            Table = UICanvas.Stage.AddElement(new Table());
            Table.SetFillParent(true).Top();
            UICanvas.SetRenderLayer(-1000);
        }
Example #32
0
        private int CreateLine(int y, string keyboard, UICanvas canvas)
        {
            int w = Size.Width - (((keyboard.Length) + 1) * SPACE_BETWEEN_BUTTONS);
            w = w / (keyboard.Length);

            int h = Size.Height - (SPACE_BETWEEN_BUTTONS * 5);
            h = h / 4;

            float x = Location.X + SPACE_BETWEEN_BUTTONS;

            foreach (var i in keyboard)
            {
                var button = canvas.Add<GradientButton>(() => new GradientButton()
                {
                    FontStyle = this.FontStyle,
                    Location = new System.Drawing.Point((int)x, y),
                    Size = new System.Drawing.Size((int)w, (int)h),
                    MaskImage = this.MaskImage,
                    Gradient = this.AlfanumericButtonsGradient
                });

                switch (i)
                {
                    case '\u0020':
                        button.Text = "Boşluk";
                        button.OnClickEvent += new EventHandler(delegate(object sender, EventArgs e)
                        {
                            OnCharPressed('\u0020', KeyboardControl.SpaceBar);
                        });
                        break;

                    case '\u0025':
                        button.Text = "abc";
                        button.Gradient = this.ControlButtonsGradient;
                        button.OnClickEvent += new EventHandler(delegate(object sender, EventArgs e)
                        {
                            this.NumericKeyboard = !this.NumericKeyboard;
                        });
                        break;

                    case '\u0021':
                        button.Gradient = this.ControlButtonsGradient;
                        button.Text = "123";
                        button.OnClickEvent += new EventHandler(delegate(object sender, EventArgs e)
                        {
                            this.NumericKeyboard = !this.NumericKeyboard;
                        });
                        break;

                    case '\u0022':
                        button.Text = "Geri";
                        button.Gradient = this.ControlButtonsGradient;
                        button.OnClickEvent += new EventHandler(delegate(object sender, EventArgs e)
                        {
                            OnCharPressed('\u0022', KeyboardControl.Back);
                        });
                        break;

                    case '\u0023':
                        button.Text = "Sil";
                        button.Gradient = this.ControlButtonsGradient;
                        button.OnClickEvent += new EventHandler(delegate(object sender, EventArgs e)
                        {
                            OnCharPressed('\u0023', KeyboardControl.Backspace);
                        });
                        break;

                    case '\u0024':
                        button.Text = "Ok";
                        button.Gradient = this.ControlButtonsGradient;
                        button.OnClickEvent += new EventHandler(delegate(object sender, EventArgs e)
                        {
                            OnCharPressed('\u0024', KeyboardControl.Enter);
                        });

                        break;

                    default:
                        button.Text = i.ToString();
                        button.OnClickEvent += new EventHandler(delegate(object sender, EventArgs e)
                        {
                            OnCharPressed(((GradientButton)sender).Text[0], KeyboardControl.Char);
                        });

                        break;
                }

                x += (SPACE_BETWEEN_BUTTONS + w);
            }

            return h;
        }
Example #33
0
    void Start()
    {
        mStats = new Stats (1, 60, 12, 2, 0, new int[] { 20, 4, 2, 0 });
        mRigidBody = GetComponent<Rigidbody> ();
        mAnimator = GetComponent<Animator> ();
        mFacingDirection = Vector2.right;
        mDying = false;

        mTarget = GameObject.Find ("Player").transform;

        expGiven = 15;
        //expGiven = 15 - 2 * (GameObject.Find ("Player").GetComponent<Player> ().mStats.Level - mStats.Level);

        mFloorControllerRef = FindObjectOfType<FloorController> ();
        mFloorBoundary = new float[4];
        mSpriteRenderer = gameObject.GetComponentInChildren<SpriteRenderer> ();
        mInitialOrderInLayer = (int)(transform.position.y);
        floorBoundaryInitialized = false;

        AudioSource[] audioSources = GetComponents<AudioSource> ();
        normalHit = audioSources [0];
        strongHit = audioSources [1];
        knifeHit = audioSources [2];

        uiCanvas = (UICanvas)GameObject.FindGameObjectWithTag ("UICanvas").GetComponent<UICanvas> ();
    }
Example #34
0
    void Start()
    {
        neanderthalHolder = new GameObject[neanderthalNumber];
        hoboHolder = new GameObject[hoboNumber];

        mStats = new Stats (1, 70, 18, 2, 0, new int[] { 20, 4, 2, 0 });
        mAnimator = GetComponent<Animator> ();

        mDying = false;

        mTarget = GameObject.Find ("Player").transform;

        AudioSource[] audioSources = GetComponents<AudioSource> ();
        normalHit = audioSources [0];
        strongHit = audioSources [1];
        dissapearing = audioSources [2];
        hoboAppearing = audioSources [3];
        neanderthalAppearing = audioSources [4];

        uiCanvas = (UICanvas)GameObject.FindGameObjectWithTag ("UICanvas").GetComponent<UICanvas> ();
    }
Example #35
0
    void Start()
    {
        mAnimator = GetComponent<Animator> ();
        mRigidBody = GetComponent<Rigidbody> ();
        InitStats (1, 100, 15, 5, 5);
        mFacingDirection = Vector2.right;
        mJumping = false;
        mSliding = false;
        mDashing = false;
        mNormalAttack = -1;
        mStrongAttack = 0;
        mGroundY = transform.position.y;

        mMoveSpeedX = 4.0f;
        mMoveSpeedY = 2.5f;
        mJumpForce = 6.5f;
        mGravityScale = 0.8f;
        hitTimer = hitWait;

        // Init Floor stuff
        mFloorControllerRef = FindObjectOfType<FloorController> ();
        mFloorBoundary = new float[4];
        mSpriteRenderer = gameObject.GetComponentInChildren<SpriteRenderer> ();
        mInitialOrderInLayer = (int)(transform.position.y);
        floorBoundaryInitialized = false;

        // before using the healthbar, check if stats need to be set:
        if (GameObject.FindGameObjectWithTag ("GameController") != null && PlayerPrefs.GetInt ("set_player_stats") == 1) {
            GameObject.FindGameObjectWithTag ("GameController").SendMessage ("SetStats", mStats);
        }

        // Init HealthBar Stuff
        mHealthBarRef = GameObject.FindGameObjectWithTag ("PlayerHealth").GetComponent<HealthBar> ();
        mHealthBarRef.SetMaxHealth (mStats.MaxHp);
        mHealthBarRef.SetHealth (mStats.Hp);

        //AudioSource[] audioSources = GetComponents<AudioSource> ();
        uiCanvas = (UICanvas)GameObject.FindGameObjectWithTag ("UICanvas").GetComponent<UICanvas> ();

        // get the shadow. it's the last element in the childern.
        SpriteRenderer[] childSpriteRenderers = gameObject.GetComponentsInChildren<SpriteRenderer> ();
        mShadow = childSpriteRenderers [childSpriteRenderers.Length - 1].gameObject;

        //Audio init
        AudioSource[] audioSources = GetComponents<AudioSource> ();
        deflating = audioSources [0];
        running = audioSources [1];
        health = audioSources [2];

        timerForSlide = 0;

        if (GameObject.Find ("LevelText") != null) {
            levelText = GameObject.Find ("LevelText").GetComponent<Text> ();
            if (mStats.Level <= 1) {
                levelText.text = "F";
                levelText.color = new Color (1, 0, 0);
            } else {
                SetLevelLabel ();
            }
        }
    }
Example #36
0
 /// <summary>
 /// On Monobehaviour Awake, save a reference of this instance in a static variable.
 /// </summary>
 public void Awake()
 {
     UICanvas.canvas = this;
 }