void Start()
    {
        state = STATE_SPLASH;

        FutileParams fparams = new FutileParams(true, true, false, false); //landscape left, right, portrait, portraitUpsideDown

        fparams.AddResolutionLevel(1024.0f, 1.0f, 1.0f, "");               //max width, displayScale, resourceScale, resourceSuffix

        fparams.backgroundColor = RXUtils.GetColorFromHex("555555");
        fparams.origin          = new Vector2(0.5f, 0.5f);

        Futile.instance.Init(fparams);

        Futile.atlasManager.LoadAtlas("Atlases/lake_monster2");
        Futile.atlasManager.LogAllElementNames();

        MetaContainer.loadFont("Arial-Black", 120, "arial_black_120", "Atlases/arial_black_120", 0f, 0f);
        MetaContainer.loadFont("BrushScriptStd", 16, "BrushScriptStd_64", "Atlases/BrushScriptStd_64", 4f, -12f);

        ScreenManager.init(this, "");

        splash = new GameScreen("greetings_lochness_cleanup");
        splash.buttons["start"].SignalRelease += handleLevels;
        ScreenManager.loadScreen(splash, ScreenSourceDirection.Instant);
    }
    public bool TestForHumans()
    {
        //no need to cache rects, we're comparing many:1 not many:many
        foreach (Human human in humans)
        {
            Rect test = new Rect(human.x - human.body.width / 2, human.y - human.body.height / 2, human.body.width, human.body.height);

            if (tentaclePieces.Count > 0)
            {
                //just the tip of the tentacle
                FSprite tentacle = tentaclePieces.GetLastObject();
                if (TestCircleRect(tentacle.x, tentacle.y, tentacle.width / 2, test))
                {
                    tentacle.color = RXUtils.GetColorFromHex("ff0000");
                    hasAHuman      = true;
                    fishFood       = human;
                    humans.Remove(human);
                    return(true);
                }
                else
                {
                    tentacle.color = RXUtils.GetColorFromHex("ffffff");
                }
            }
        }

        return(false);
    }
    public void Init(FContainer container, uint color, bool shouldUpdateColliders)
    {
        _container = container;

        _container.AddChild(_drawHolder = new FContainer());

        _color = RXUtils.GetColorFromHex(color);

        this.shouldUpdateColliders = shouldUpdateColliders;

        Collider[] colliders = gameObject.GetComponents <Collider>();

        int colliderCount = colliders.Length;

        for (int c = 0; c < colliderCount; c++)
        {
            Collider collider = colliders[c];

            FNode newNode = null;

            if (collider is BoxCollider)
            {
                FSprite sprite = new FSprite("Debug/Square");
                sprite.color = _color;

                newNode = sprite;
            }
            else if (collider is SphereCollider)
            {
                FSprite sprite = new FSprite("Debug/Circle");
                sprite.color = _color;

                newNode = sprite;
            }

            if (newNode != null)
            {
                _drawHolder.AddChild(newNode);
                _nodes.Add(newNode);
            }
        }

        FPPolygonalCollider mesh2D = gameObject.GetComponent <FPPolygonalCollider>();

        if (mesh2D != null)
        {
            FPDebugPolygonColliderView debugView = new FPDebugPolygonColliderView("Debug/Triangle", mesh2D);
            debugView.color = _color;

            _drawHolder.AddChild(debugView);
            _nodes.Add(debugView);
        }

        Update();
        if (!shouldUpdateColliders)
        {
            UpdateColliders();                                //always update the colliders the first time
        }
    }
Beispiel #4
0
    private void Start()
    {
        instance = this;

        Go.defaultEaseType       = EaseType.Linear;
        Go.duplicatePropertyRule = DuplicatePropertyRuleType.RemoveRunningProperty;

        //Time.timeScale = 0.1f;

        bool isIPad = SystemInfo.deviceModel.Contains("iPad");

        bool shouldSupportPortraitUpsideDown = isIPad;         //only support portrait upside-down on iPad

        FutileParams fparams = new FutileParams(true, true, true, shouldSupportPortraitUpsideDown);

        fparams.backgroundColor = RXUtils.GetColorFromHex(0x212121);
        fparams.shouldLerpToNearestResolutionLevel = true;
        fparams.resolutionLevelPickMode            = FResolutionLevelPickMode.Downwards;

        fparams.AddResolutionLevel(640.0f, 1.0f, 1.0f, "");
        fparams.AddResolutionLevel(1280.0f, 2.0f, 1.0f, "");
        fparams.AddResolutionLevel(1920.0f, 3.0f, 1.0f, "");
        fparams.AddResolutionLevel(2560.0f, 4.0f, 1.0f, "");

        fparams.origin = new Vector2(0.5f, 0.5f);

        Futile.instance.Init(fparams);

        FFacetType.Quad.maxEmptyAmount  = 100;
        FFacetType.Quad.expansionAmount = 100;
        FFacetType.Quad.initialAmount   = 100;

        FAtlas mainAtlas = Futile.atlasManager.LoadAtlas("Atlases/MainAtlas");

        mainAtlas.texture.filterMode = FilterMode.Point;

        TOFonts.Load();

        Config.Setup();

        Wolf.WolfAnimation.SetupAnimations();
        Human.HumanAnimation.SetupAnimations();

        core = new Core();
        Futile.stage.AddChild(core);

        //FSoundManager.PlayMusic ("NormalMusic",0.5f);

        Futile.screen.SignalResize += HandleSignalResize;
        HandleSignalResize(false);
    }
Beispiel #5
0
    public static void init(MonoBehaviour handler, string backdropSprite = "")
    {
        coroutineHandler = handler;

        backdrop = null;
        if (backdropSprite != "")
        {
            backdrop        = new FSprite(backdropSprite);
            backdrop.scaleX = Futile.screen.width / backdrop.width;
            backdrop.scaleY = Futile.screen.height / backdrop.height;
            // NOTE: The following two lines recolor the backdrop sprite
            backdrop.shader = FShader.SolidColored;
            backdrop.color  = RXUtils.GetColorFromHex("555555");
        }

        screenLayer = new FContainer();

        Futile.stage.AddChild(screenLayer);
    }
Beispiel #6
0
    private void Start()
    {
        Go.defaultEaseType       = EaseType.Linear;
        Go.duplicatePropertyRule = DuplicatePropertyRuleType.RemoveRunningProperty;

        // Uncomment if you need to delete bad save data on startup
        // PlayerPrefs.DeleteAll();

        //Time.timeScale = 0.1f; //use for checking timings of things in slow motion

        FutileParams fparams = new FutileParams(true, true, false, false);

        fparams.backgroundColor = RXUtils.GetColorFromHex(0x050122);
        fparams.shouldLerpToNearestResolutionLevel = false;
        fparams.resolutionLevelPickMode            = FResolutionLevelPickMode.Closest;

        bool shouldHaveScale1 = true;
        bool shouldHaveScale2 = true;
        bool shouldHaveScale4 = true;

                #if UNITY_WEBPLAYER
        //webplayer has everything but scale2 stripped out
        shouldHaveScale1 = false;
        shouldHaveScale4 = false;
                #endif

        if (shouldHaveScale1)
        {
            fparams.AddResolutionLevel(480.0f, 1.0f, 1.0f, "_Scale1");                                      //iPhone
        }
        if (shouldHaveScale2)
        {
            fparams.AddResolutionLevel(960.0f, 2.0f, 2.0f, "_Scale2");                                      //iPhone retina
        }
        if (shouldHaveScale2)
        {
            fparams.AddResolutionLevel(1024.0f, 2.0f, 2.0f, "_Scale2");                                     //iPad
        }
        if (shouldHaveScale2)
        {
            fparams.AddResolutionLevel(1136.0f, 2.0f, 2.0f, "_Scale2");                                     //iPhone 5 retina
        }
        if (shouldHaveScale2)
        {
            fparams.AddResolutionLevel(1280.0f, 2.0f, 2.0f, "_Scale2");                                     //Nexus 7
        }
        if (shouldHaveScale4)
        {
            fparams.AddResolutionLevel(2048.0f, 4.0f, 4.0f, "_Scale4");                                     //iPad Retina
        }
        //FOR SCREENSHOTS
//		if(shouldHaveScale1) fparams.AddResolutionLevel(480.0f,		1.0f,	2.0f,	"_Scale2"); //iPhone
//		if(shouldHaveScale2) fparams.AddResolutionLevel(960.0f,		2.0f,	2.0f,	"_Scale2"); //iPhone retina
//		if(shouldHaveScale2) fparams.AddResolutionLevel(1024.0f,	2.0f,	4.0f,	"_Scale4"); //iPad
//		if(shouldHaveScale2) fparams.AddResolutionLevel(1136.0f,	2.0f,	4.0f,	"_Scale4"); //iPhone 5 retina
//		if(shouldHaveScale2) fparams.AddResolutionLevel(1280.0f,	2.0f,	4.0f,	"_Scale4"); //Nexus 7
//		if(shouldHaveScale4) fparams.AddResolutionLevel(2048.0f,	4.0f,	4.0f,	"_Scale4"); //iPad Retina

        fparams.origin = new Vector2(0.5f, 0.5f);

        Futile.instance.Init(fparams);

        Futile.atlasManager.LoadAtlas("Atlases/MainAtlas");
        //Futile.atlasManager.LoadImage("Atlases/Fonts/Raleway");
        //Futile.atlasManager.LoadImage("Atlases/Fonts/Ostrich");

        FTextParams textParams;

        textParams = new FTextParams();
        textParams.kerningOffset    = -0.0f;
        textParams.lineHeightOffset = -15.0f;
        Futile.atlasManager.LoadFont("Raleway", "Fonts/Raleway" + Futile.resourceSuffix, "Atlases/Fonts/Raleway" + Futile.resourceSuffix, -1.0f, -1.0f, textParams);

//
//		textParams = new FTextParams();
//		textParams.kerningOffset = -0.0f;
//		textParams.lineHeightOffset = -15.0f;
//		Futile.atlasManager.LoadFont("Ostrich","Atlases/Fonts/Ostrich", "Atlases/Fonts/Ostrich"+Futile.resourceSuffix, 0.0f,-2.0f,textParams);
//
        for (int s = 0; s < 10; s++)
        {
            FSoundManager.PreloadSound("Musical/Note" + s + "_bass");
            FSoundManager.PreloadSound("Musical/Note" + s + "_normal");
        }

        Futile.stage.AddChild(new Keeper());         //keeper statically retains itself and never gets removed
    }
Beispiel #7
0
    public void Reorder(bool shouldWaitUntilMathModeFinishes, bool shouldScrollToTop, bool isFlipping)
    {
        if (_slots.Count == 0)
        {
            return;                           //no need sorting things that don't exist :)
        }
        if (shouldWaitUntilMathModeFinishes)
        {
            for (int s = 0; s < _slots.Count; s++)
            {
                if (_slots[s].scoreBox.mathMode.amount > 0)
                {
                    return;                                                        //don't sort if one of them is in math mode
                }
            }
        }

        _isFlipping = isFlipping;

        List <Slot> originalSlots = new List <Slot>(_slots);       //create a copy

        Slot oldWinningSlot = _slots[0];

        float totalHeight = _slots.Count * (Config.SLOT_HEIGHT + Config.PADDING_M) - Config.PADDING_M;

        _minScrollY = Mathf.Min(0, -(totalHeight - _height) / 2 - Config.PADDING_M);
        _maxScrollY = Mathf.Max(0, (totalHeight - _height) / 2 + Config.PADDING_M);

        _canScroll = (totalHeight > _height);

        _slots.Sort(SlotSorter);

        for (int s = 0; s < _slots.Count; s++)
        {
            Slot slot = _slots[s];

            slotContainer.AddChildAtIndex(slot, 0);            //add at the bottom

            float newY = totalHeight * 0.5f - Config.SLOT_HEIGHT * 0.5f - (Config.SLOT_HEIGHT + Config.PADDING_M) * s;

            if (slot.index == -1)            //it's new!
            {
                slot.y = newY;

                float delay;

                if (_isInitializing)
                {
                    delay = 0.2f + (float)s * 0.1f;
                }
                else
                {
                    delay = _slots.Count == 1 ? 0 : 0.3f;                     //only delay if there are other players
                }

                //note how we make the tween longer AND delay it by the delay. weird effect :)
                Go.killAllTweensWithTarget(slot.buildInTweenable);
                Go.to(slot.buildInTweenable, 0.5f + delay, new TweenConfig().floatProp("amount", 1.0f).setDelay(delay));
            }
            else if (slot.index < s)            //moving down
            {
                Go.killAllTweensWithTarget(slot.buildInTweenable);
                Go.to(slot.buildInTweenable, 0.5f, new TweenConfig().floatProp("amount", 1.0f));

                Go.killAllTweensWithTarget(slot);
                Go.to(slot, 0.5f, new TweenConfig().floatProp("y", newY).setEaseType(EaseType.ExpoInOut));

                float delta       = s - slot.index;
                float scaleAmount = 0.04f + delta * 0.0075f;

                //slot shrink more the farther it travels downward

                RXTweenable tw = new RXTweenable(0.0f);
                tw.SignalChange += () =>
                {
                    slot.scale = 1.0f - scaleAmount * RXEase.UpDown(tw.amount, RXEase.SineIn);
                };

                Go.to(tw, 0.5f, new TweenConfig().floatProp("amount", 1.0f).setEaseType(EaseType.Linear));
            }
            else if (slot.index > s)            //moving up
            {
                Go.killAllTweensWithTarget(slot.buildInTweenable);
                Go.to(slot.buildInTweenable, 0.5f, new TweenConfig().floatProp("amount", 1.0f));

                Go.killAllTweensWithTarget(slot);
                Go.to(slot, 0.5f, new TweenConfig().floatProp("y", newY).setEaseType(EaseType.ExpoInOut));

                //slot grows more the farther it travels upward
                float delta       = slot.index - s;
                float scaleAmount = 0.04f + delta * 0.0075f;

                RXTweenable tw = new RXTweenable(0.0f);
                tw.SignalChange += () =>
                {
                    slot.scale = 1.0f + scaleAmount * RXEase.UpDown(tw.amount, RXEase.SineIn);
                };

                Go.to(tw, 0.5f, new TweenConfig().floatProp("amount", 1.0f).setEaseType(EaseType.Linear));
            }
            else
            {
                if (slot.y != newY)
                {
                    Go.killAllTweensWithTarget(slot.buildInTweenable);
                    Go.to(slot.buildInTweenable, 0.5f, new TweenConfig().floatProp("amount", 1.0f));

                    Go.killAllTweensWithTarget(slot);
                    Go.to(slot, 0.5f, new TweenConfig().floatProp("y", newY).setEaseType(EaseType.ExpoInOut));
                }
            }

            slot.index = s;
        }

        bool isThereANewWinner = (oldWinningSlot != _slots[0]);

        if (isThereANewWinner || shouldScrollToTop)
        {
            ScrollToTop(1.0f);
        }
        else if (!_canScroll)
        {
            ScrollToTop(0.5f);             //make sure it's always centered
        }

        if (isThereANewWinner)
        {
            //TODO: play winner sound
            _slots[0].player.color.PlayNormalSound();
        }

        if (!RXUtils.AreListsEqual(_slots, originalSlots))
        {
            FSoundManager.PlaySound("UI/Sort");
        }

        SKDataManager.MarkDirty();

        _isFlipping = false;
    }
    public bool TestForCollisions()
    {
        Dictionary <Enemy, Rect> cached_rects = new Dictionary <Enemy, Rect>();

        foreach (Enemy enemy in enemies)
        {
            if (!cached_rects.ContainsKey(enemy))
            {
                //this code puts bright orange debug rects over the rect of the sonar bits

                if (!debugRects.ContainsKey(enemy))
                {
                    debugRects[enemy] = new FSprite("debug_rect");
//					AddChild(debugRects[enemy]);
                }

                Vector2 sonar_pos = enemy.LocalToOther(enemy.sonar.GetPosition(), this);
                cached_rects[enemy] = new Rect(sonar_pos.x - enemy.sonar.width / 2,
                                               sonar_pos.y - enemy.sonar.height / 2,
                                               enemy.sonar.width,
                                               enemy.sonar.height);

//				debugRects[enemy].x = cached_rects[enemy].center.x;
//				debugRects[enemy].y = cached_rects[enemy].center.y;
//				debugRects[enemy].width = cached_rects[enemy].width;
//				debugRects[enemy].height = cached_rects[enemy].height;
            }
        }


        foreach (TentaclePiece tentacle in tentaclePieces)
        {
            bool got_one = false;
            foreach (Enemy enemy in enemies)
            {
                //first see if we're even in the rect...
                if (TestCircleRect(tentacle.x, tentacle.y, tentacle.width / 2, cached_rects[enemy]))
                {
                    Vector2 vertex_a = enemy.LocalToOther(enemy.sonar_vert_1, this);
                    Vector2 vertex_b = enemy.LocalToOther(enemy.sonar_vert_2, this);
                    Vector2 vertex_c = enemy.LocalToOther(enemy.sonar_vert_3, this);

                    if (TestPointInTriangle(vertex_a.x, vertex_a.y, vertex_b.x, vertex_b.y, vertex_c.x, vertex_c.y, tentacle.tipX, tentacle.tipY))
                    {
                        got_one = true;
                        return(true);
                    }
                }
            }

            if (got_one)
            {
                tentacle.color = RXUtils.GetColorFromHex("ff0000");
            }
            else
            {
                tentacle.color = RXUtils.GetColorFromHex("ffffff");
            }
        }

        return(false);
    }