Beispiel #1
0
    void M8.IPoolSpawn.OnSpawned(M8.GenericParams parms)
    {
        mCellIndex = new GridCell {
            b = 0, row = 0, col = 0
        };
        _cellSize = new GridCell {
            b = 1, row = 1, col = 1
        };


        if (parms != null)
        {
            if (parms.ContainsKey(parmData))
            {
                _data = parms.GetValue <GridEntityData>(parmData);
            }

            if (parms.ContainsKey(parmCellIndex))
            {
                mCellIndex = parms.GetValue <GridCell>(parmCellIndex);
            }

            if (parms.ContainsKey(parmCellSize))
            {
                _cellSize = parms.GetValue <GridCell>(parmCellSize);
            }
        }

        container.AddEntity(this);

        RefreshPosition();
        RefreshBounds();
    }
Beispiel #2
0
    public void ApplyMaterial(GridEntityData data)
    {
        var mat = data.material;

        mShaderPulseColorId = data.shaderPulseColorId;

        if (!material || !mat || material.name != mat.name)
        {
            if (material)
            {
                Destroy(material);
                material = null;
            }

            if (mat)
            {
                material = new Material(mat);
                rendererDisplay.sharedMaterial = material;

                //apply alpha
                var clr = material.GetColor(data.shaderColorId);
                clr.a = _alpha;
                material.SetColor(data.shaderColorId, clr);

                //apply pulse scale
                material.SetFloat(data.shaderPulseScaleId, _pulseScale);

                pulseColorDefault = material.GetColor(data.shaderPulseColorId);
            }
            else
            {
                rendererDisplay.sharedMaterial = null;
            }
        }
    }
Beispiel #3
0
    void M8.IPoolDespawn.OnDespawned()
    {
        if (container)
        {
            container.RemoveEntity(this);
        }

        _data      = null;
        mContainer = null;
    }
Beispiel #4
0
    public bool IsEntityContain(GridEntityData dat)
    {
        for (int i = 0; i < entities.Count; i++)
        {
            var ent = entities[i];
            if (ent.data == dat)
            {
                return(true);
            }
        }

        return(false);
    }
Beispiel #5
0
    public int GetHeightRequirement(GridEntityData dat)
    {
        for (int i = 0; i < goals.Length; i++)
        {
            var goal = goals[i];
            if (goal.data == dat)
            {
                return(goal.unitHeightRequire);
            }
        }

        return(0);
    }
Beispiel #6
0
    public int GetVolumeCount(GridEntityData entDat)
    {
        int count = 0;

        for (int i = 0; i < entities.Count; i++)
        {
            var ent = entities[i];
            if (ent.data == entDat)
            {
                count += ent.cellSize.volume;
            }
        }

        return(count);
    }
Beispiel #7
0
    public void Setup(GridEntityData dat)
    {
        data = dat;

        if (icon)
        {
            icon.sprite = data.icon;
            //icon.SetNativeSize();
        }

        if (titleText)
        {
            titleText.text = M8.Localize.Get(data.nameTextRef);
        }

        if (cardDrag)
        {
            cardDrag.gameObject.SetActive(false);
        }
    }
Beispiel #8
0
 void OnMapChanged(GridEntityData entDat)
 {
     RefreshCount();
 }
Beispiel #9
0
 void OnMapUpdate(GridEntityData entDat)
 {
     RefreshDisplay();
 }