Exemple #1
0
    public static JobComponent ScheduleJobControllerInWorld(
        WorldComponent worldComponent, Job job)
    {
        GameObject   entityObject    = new GameObject();
        JobComponent entityComponent = entityObject.AddComponent <JobComponent>();

        entityObject.transform.SetParent(worldComponent.transform);

        IndicatorBar bar = IndicatorBar.Instantiate(entityObject);

        bar.GetSizeCallback = new IndicatorBar.GetSize(
            () => { return(job.CurrentStage().CurrentProgress()); }
            );

        entityObject.name   = job.id + "_indicator";
        entityComponent.job = job;

        PolygonCollider2D collider = entityObject.AddComponent <PolygonCollider2D>();

        collider.points = new Vector2[] {
            new Vector2(-0.5f, -0.5f),
            new Vector2(-0.5f, 0.5f),
            new Vector2(0.5f, 0.5f),
            new Vector2(0.5f, -0.5f)
        };

        entityComponent.spriteRenderer        = entityObject.AddComponent <SpriteRenderer>();
        entityComponent.spriteRenderer.sprite = SpriteLoader.GetSprite("test");

        return(entityComponent);
    }
        public void SetupCanvasIcon()
        {
            Vector2    anchor       = new Vector2(x, y);
            GameObject canvasSprite = CanvasUtil.CreateImagePanel
                                      (
                _canvas,
                SpriteLoader.GetSprite(spriteName),
                new CanvasUtil.RectData(Vector2.zero, Vector2.zero, anchor, anchor + new Vector2(1f / 15f, 0.1f))
                                      );

            // Add a canvas group so we can fade it in and out
            canvasGroup = canvasSprite.AddComponent <CanvasGroup>();
            canvasGroup.blocksRaycasts = false;
            canvasGroup.interactable   = false;
            if (!BingoUI.globalSettings.alwaysDisplay)
            {
                canvasGroup.gameObject.SetActive(false);
            }

            GameObject text = CanvasUtil.CreateTextPanel
                              (
                canvasSprite,
                "0",
                23,
                TextAnchor.LowerCenter,
                new CanvasUtil.RectData(Vector2.zero, Vector2.zero, Vector2.zero, Vector2.one)
                              );

            textPanel       = text.GetComponent <Text>();
            textPanel.color = Color.black;
        }
Exemple #3
0
    public void DoTransition()
    {
        if (GameObject.Find("DEMO") != null)
        {
            var list = sploader.GetSpritesName();
            int idx  = Random.Range(0, list.Count);
            effectName = list[idx];
        }
        else
        {
            var wsclient = GameObject.Find("WSClient").GetComponent <WSClient>();
            int idx      = Random.Range(0, wsclient.arData.EnabledEffects.Count);
            effectName = wsclient.arData.EnabledEffects[idx];
        }

        Debug.Log(effectName);
        currentColor = Random.Range(0, 4);

        Effect.GetComponent <Image>().sprite = sploader.GetSprite(effectName);
        Effect.GetComponent <Image>().color  = colors[currentColor];

        isTransition = true;
        Effect.SetActive(true);
        Arrow.SetActive(true);
        effectInitPos = Effect.transform.position;
    }
Exemple #4
0
 public void GetWeaponek(int weaponID)
 {
     for (int i = 0; i < weaponSprite.Length; i++)
     {
         // if (photonView.isMine)
         weaponSprite[i].sprite = SpriteLoader.GetSprite(spriteNameID + weaponID.ToString());
         Debug.Log(spriteNameID + PlayerPrefs.GetInt("WeaponID").ToString());
     }
 }
Exemple #5
0
    public void Spawn(World world, Vector2 position)
    {
        name = entity.id;

        if (entity is EntityAnimated)
        {
            name = ((EntityAnimated)entity).name;
        }
        spriteRenderer.sprite = SpriteLoader.GetSprite("character", "one");
    }
Exemple #6
0
    void Start()
    {
        gameObject.GetComponent <SpriteRenderer>().sprite = SpriteLoader.GetSprite("Blocks/grass");
        Hardness             = 0.5f;
        this.UnlocalizedName = "grass";
        Image        = GetComponent <SpriteRenderer>().sprite;
        MaxStackSize = StaticData.DefaultStackMaxSize;

        InvokeRepeating("UpdateOncePerSecond", 0f, 1.0f);
    }
Exemple #7
0
 public void SetEntitySprite(World world)
 {
     if (Emitter is Entity)
     {
         SpriteInfo spriteInfo = (Emitter as Entity).spriteInfo;
         if (spriteInfo.type == "connecting")
         {
             spriteRenderer.sprite = SpriteLoader.GetSprite(spriteInfo.id, ((EntityBuilding)Emitter).GetConnectingNeighbours());
         }
         else
         {
             spriteRenderer.sprite = SpriteLoader.GetSprite(spriteInfo.id);
         }
     }
 }
Exemple #8
0
    public void ChangeColor(int score)
    {
        //some default Color
        // Color m_color = Color.white;

        //your score color logic stuff herer
        if (score < 10)
        {
            LevelOfSkin = 1.1f;

            spriteName = "Kot-gladiator_0";
        }

        if (score >= 10) //&& score <= 19)
        {
            LevelOfSkin = 1.2f;
            spriteName  = "Kot-gladiator2_0";
        }
        if (score >= 20 && score <= 29)
        {
            LevelOfSkin = 1.3f;
            // spriteName = "HeroParts7_3";
        }
        if (score >= 30 && score <= 39)
        {
            LevelOfSkin = 1.4f;
            //  spriteName = "HeroParts2_3";
        }
        if (score >= 40 && score <= 49)
        {
            LevelOfSkin = 1.5f;
            // spriteName = "HeroParts4_3";
        }
        if (score >= 50)
        {
            //spriteName = "HeroParts6_3";
            LevelOfSkin = 1.6f;
        }


        spr = SpriteLoader.GetSprite(spriteName);
        m_spriteRender[0].sprite = spr;
    }
Exemple #9
0
    public static EntityComponent SpawnEntityControllerInWorld(
        WorldComponent worldComponent, Entity entity,
        Vector2 coord)
    {
        GameObject      entityObject    = new GameObject();
        EntityComponent entityComponent = entityObject.AddComponent <EntityComponent>();

        entityObject.transform.SetParent(worldComponent.transform);
        //entityComponent.SetPosition(coord);

        PolygonCollider2D collider = entityObject.AddComponent <PolygonCollider2D>();

        collider.points = new Vector2[] {
            new Vector2(-0.5f, -0.5f),
            new Vector2(-0.5f, 0.5f),
            new Vector2(0.5f, 0.5f),
            new Vector2(0.5f, -0.5f)
        };

        entityComponent.spriteRenderer        = entityObject.AddComponent <SpriteRenderer>();
        entityComponent.spriteRenderer.sprite = SpriteLoader.GetSprite("test");

        return(entityComponent);
    }
    private void Start()
    {
        // いいね!スプライトロード
        sploader = new SpriteLoader();
        sploader.Load("LikeEffects");

        // 全てのエフェクトのチェックボックスと画像の表示
        var parent      = this.transform.Find("Viewport").Find("Content");
        var effectNames = sploader.GetSpritesName();

        Effects = effectNames.ToDictionary(eff => eff, val => true);
        foreach (var name in effectNames)
        {
            var item = Object.Instantiate(Template, parent) as GameObject;
            item.SetActive(true);
            var image = item.transform.Find("Image").GetComponent <Image>();
            image.sprite = sploader.GetSprite(name);
            image.color  = Color.black;
            item.transform.Find("Toggle").GetComponent <Toggle>().onValueChanged.AddListener((value) =>
            {
                Effects[name] = value;
            });
        }
    }
Exemple #11
0
    void Start()
    {
        if (PlayerPrefs.GetInt("PlayStyle") == 0)
        {
            weaponName = "Sword";
        }
        else
        if (PlayerPrefs.GetInt("PlayStyle") == 1)
        {
            weaponName = "Swords";
        }
        else
        if (PlayerPrefs.GetInt("PlayStyle") == 2)
        {
            weaponName = "Dagger";
        }
        else
        if (PlayerPrefs.GetInt("PlayStyle") == 3)
        {
            weaponName = "BigSword";
        }

        gameObject.GetComponent <Image>().sprite = SpriteLoader.GetSprite(weaponName + PlayerPrefs.GetInt("WeaponID").ToString() + "Ic");;
    }
Exemple #12
0
    // Reminder since I keep forgetting: The UI must be built while in play mode for the buttons to work
    public void BuildUI()
    {
        if (testUI)
        {
            return;
        }

        treeItems = new List <TreeView.TreeItem> ();
        foreach (var item in testTreeItems)
        {
            treeItems.Add(new TreeView.TreeItem(item, i => (i as TestTreeItem).Name, i => (i as TestTreeItem).Count != 0, 0));
        }

        Window basePanel = UIKit.CreateUI <Window>(appCanvas.transform as RectTransform, "testUI");

        testUI = basePanel.gameObject;

        basePanel
        .Title("A test")
        .Vertical()
        .ControlChildSize(true, true)
        .ChildForceExpand(false, false)
        .PreferredSizeFitter(true, true)
        .Anchor(AnchorPresets.MiddleCenter)
        .Pivot(PivotPresets.TopLeft)
        .PreferredWidth(300)
        .Add <UIButton>()
        .Text("Button A")
        .OnClick(ButtonAction)
        .FlexibleLayout(true, false)
        .Finish()
        .Add <Layout>()
        .Horizontal()
        .ControlChildSize(true, true)
        .ChildForceExpand(false, false)
        .Anchor(AnchorPresets.HorStretchTop)
        .FlexibleLayout(true, false)
        .Add <UIEmpty>()
        .FlexibleLayout(true, true)
        .Finish()
        .Add <UIButton>()
        .Text("B")
        .OnClick(ButtonAction)
        .Finish()
        .Add <UIEmpty>()
        .FlexibleLayout(true, true)
        .Finish()
        .Add <UIButton>()
        .Text("C")
        .OnClick(ButtonAction)
        .Finish()
        .Add <UIEmpty>()
        .FlexibleLayout(true, true)
        .Finish()
        .Add <UIButton>()
        .Image(SpriteLoader.GetSprite("KodeUI/Default/toggle_on"))
        .OnClick(ButtonAction)
        .Finish()
        .Finish()
        .Add <Layout>()
        .Horizontal()
        .ControlChildSize(true, true)
        .ChildForceExpand(false, false)
        .Anchor(AnchorPresets.HorStretchTop)
        .FlexibleLayout(true, false)
        .Add <UIButton>()
        .Text("Very Long text")
        .OnClick(ButtonAction)
        .FlexibleLayout(true, false)
        .Finish()
        .Add <UIEmpty>()
        .FlexibleLayout(true, true)
        .Finish()
        .Add <UIButton>()
        .Text("Is Long")
        .OnClick(ButtonAction)
        .FlexibleLayout(true, false)
        .Finish()
        .Finish()
        .Add <UIText>()
        .Text("A long text that should overflow to the next line")
        .Alignment(TextAlignmentOptions.TopLeft)
        .FlexibleLayout(true, false)
        .Finish()

        .Add <Layout>()
        .Horizontal()
        .ControlChildSize(true, true)
        .ChildForceExpand(false, false)
        .Anchor(AnchorPresets.HorStretchTop)
        .Add <UIText>(out text)
        .Text("N/A")
        .Alignment(TextAlignmentOptions.TopLeft)
        .FlexibleLayout(true, false)
        .Finish()
        .Finish()

        .Add <UIToggle>()
        .OnValueChanged(Action)
        .FlexibleLayout(false, true)
        .PreferredSize(15, 15)
        .Finish()
        .Add <UIInputField>()
        .FlexibleLayout(true, false)
        .SizeDelta(0, 0)
        .Finish()
        .Add <TreeView>(out treeView)
        .Items(treeItems)
        .OnClick(OnTreeClicked)
        .OnStateChanged(OnTreeStateChanged)
        .PreferredSize(-1, 150)
        .FlexibleLayout(true, true)
        .Finish()
        .Finish();


        // needed in the editor to have the proper layout when not in play mode
        LayoutRebuilder.ForceRebuildLayoutImmediate(basePanel.rectTransform);


        // TODO:
        // * LayoutElement sur tout ? Flexible  Size H/V en fonction du layout parent ?
        // * ContentSizeFitter sur tout/certain ? H/V en fonction du layout parent ?
    }