/// <summary>
    /// $b$Get certain DecalExpeditor on this DecalHolder (parented to this GameObject)$bb$
    /// </summary>
    /// <param name="decalType">DecalType for search DecalExpeditor</param>
    /// <returns>$b$DecalExpeditor (parent) for all Decals of type decalType on this GameObject (Holder).$bb$</returns>
    public GameObject GetExpeditor(DecalType decalType)
    {
        GameObject result;

        _decalType2DecalObject.TryGetValue(decalType, out result);
        return(result);
    }
示例#2
0
 public void SetDecal(int x, int y, DecalType type)
 {
     foreach (var b in _blocks)
     {
         b.SetDecal(x, y, type);
     }
 }
示例#3
0
        public void AddDecal(DecalType type)
        {
            switch (type)
            {
            case DecalType.Blood:
                string decalname;
                switch (_random.Next(1, 4))
                {
                case 1:
                    decalname = "spatter_decal";
                    break;

                case 2:
                    decalname = "spatter_decal2";
                    break;

                case 3:
                    decalname = "spatter_decal3";
                    break;

                default:
                    decalname = "spatter_decal4";
                    break;
                }
                decals.Add(new TileDecal(_resourceManager.GetSprite(decalname),
                                         new Vector2D(_random.Next(0, 64), _random.Next(0, 64)), this,
                                         Color.FromArgb(165, 6, 6)));
                break;
            }
        }
示例#4
0
        public void SpawnDecalOnGround(DecalType decalType, Vector3 position)
        {
            DecalPool pool = this._pools[decalType];
            Vector3   pos  = Utility.Utils.GetGroundedPosition(position);

            pool.Get(pos + Vector3.up * this._decalGroundOffset, Quaternion.LookRotation(Vector3.down));
        }
示例#5
0
        /// <summary>
        /// Метод вызывается для каждой стороны для каждой декорации.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="s"></param>
        /// <param name="who"></param>
        /// <remarks></remarks>
        public void Update(int x, int y, Side s, WhoIs who)
        {
            //DONE: обновление источников четырех сторон. то есть сюда приходит запрос из источника, и происходит
            //обновление нужной стороны под нужный источник события.

            //сделана зависимость для отмены рисования
            if (GameController.board[x, y].m_Current is Ground)
            {
                return;
            }
            if (GameController.board[x, y].m_Current is Beton)
            {
                return;
            }
            //DONE: сделать зависимость декорации от земли где она применяется. для камня это свои картинки, для песка свои. сча любой тип это песок.
            //DONE: сделать зависимость декорации от бомбы.
            if (GameController.board[x, y].m_Current is Rock)
            {
                CurrentType = DecalType.Rock;
                PrepareSources(who, s);
            }
            if (GameController.board[x, y].m_Current is Sand)
            {
                CurrentType = DecalType.Sand;
                PrepareSources(who, s);
            }


            //UpdateSide(s, x, y)
        }
示例#6
0
        public void SetDecal(int x, int y, DecalType type)
        {
            if (x < LeftTileX || x > LeftTileX + TileWidth - 1)
            {
                return;
            }
            if (y < BottomTileY || y > BottomTileY + TileHeight - 1)
            {
                return;
            }

            var realx = x - LeftTileX;
            var realy = y - BottomTileY;

            var spritedata = _tileset.GetDecal(type);

            var tiledata   = spritedata.texture.GetPixels(0, 0, TileWidth, TileHeight);
            var sourcedata = Sprite.texture.GetPixels(TileWidth * realx, TileHeight * realy, TileWidth, TileHeight);
            var result     = new Color[tiledata.Length];

            for (var i = 0; i < tiledata.Length; i++)
            {
                result[i] = Color.Lerp(sourcedata[i], tiledata[i], tiledata[i].a);
            }


            //            for (var i = 0; i < tiledata.Length; i++)
            //                tiledata[i].a = 1f;

            Sprite.texture.SetPixels(TileWidth * realx, TileHeight * realy, TileWidth, TileHeight, result);

            _dirty = true;
        }
示例#7
0
 public static void DrawDecalToolGizmo(DecalType decalType, GizmoType gizmoType)
 {
     if ((gizmoType & GizmoType.Selected) != 0)
     {
         Gizmos.matrix = decalType.transform.localToWorldMatrix;
         Gizmos.color  = new Color(1, 1, 1, 0.7F);
         Gizmos.DrawWireCube(new Vector3(0, 0, 0), new Vector3(1, 1, 1));
         Gizmos.color = new Color(0, 0, 0, 0.7F);
         Gizmos.DrawWireCube(new Vector3(0, 0, 0), new Vector3(1.002F, 1.002F, 1.002F));
         // Arrow
         //Gizmos.matrix = Matrix4x4.identity;
         //Gizmos.DrawLine(decalType.transform.position - decalType.transform.forward * decalType.transform.localScale.z / 2
         //- decalType.transform.right * decalType.transform.localScale.x / 2
         //- decalType.transform.up * decalType.transform.localScale.y / 2, decalType.transform.position + decalType.transform.forward * decalType.transform.localScale.z / 2);
         //Gizmos.DrawLine(decalType.transform.position - decalType.transform.forward * decalType.transform.localScale.z / 2
         //+ decalType.transform.right * decalType.transform.localScale.x / 2
         //+ decalType.transform.up * decalType.transform.localScale.y / 2, decalType.transform.position + decalType.transform.forward * decalType.transform.localScale.z / 2);
         //Gizmos.DrawLine(decalType.transform.position - decalType.transform.forward * decalType.transform.localScale.z / 2
         //+ decalType.transform.right * decalType.transform.localScale.x / 2
         //- decalType.transform.up * decalType.transform.localScale.y / 2, decalType.transform.position + decalType.transform.forward * decalType.transform.localScale.z / 2);
         //Gizmos.DrawLine(decalType.transform.position - decalType.transform.forward * decalType.transform.localScale.z / 2
         //- decalType.transform.right * decalType.transform.localScale.x / 2
         //+ decalType.transform.up * decalType.transform.localScale.y / 2, decalType.transform.position + decalType.transform.forward * decalType.transform.localScale.z / 2);
     }
     else
     {
         Gizmos.DrawIcon(decalType.transform.position, "DecalIcon");
     }
 }
示例#8
0
 /// <summary>
 ///     Creates a decal in the world.
 /// </summary>
 /// <param name="decalType">The type of decal.</param>
 /// <param name="position">The position of the decal.</param>
 /// <param name="normal">The decal normal.</param>
 /// <param name="width">The decal width.</param>
 /// <param name="height">The decal height.</param>
 /// <param name="color">The decal color.</param>
 /// <param name="timeout">How long the decal exists.</param>
 public static void AddDecal(Vector3 pos, DecalType decalType,
                             float width = 1.0f, float height = 1.0f, float rCoef   = 0.1f,
                             float gCoef = 0.1f, float bCoef  = 0.1f, float opacity = 1.0f, float timeout = 20.0f)
 {
     Function.Call <int>(Hash.ADD_DECAL, (int)decalType, pos.X, pos.Y, pos.Z, 0, 0, -1.0, 0, 1.0, 0, width,
                         height, rCoef, gCoef, bCoef, opacity, timeout, 0, 0, 0);
 }
示例#9
0
 private void OnEnable()
 {
     _decalType           = target as DecalType;
     _serializeddecalType = new SerializedObject(target);
     _dWasPressed         = false;
     _cWasPressed         = false;
     _sWasPressed         = false;
 }
        public DecalInfo(string name, int index, DecalType type)
        {
            this.name  = name;
            this.index = index;
            this.type  = type;

            description = index.ToString() + ": " + name;
        }
示例#11
0
        public void AddDecal(DecalType type)
        {
            NetOutgoingMessage message = map.CreateMapMessage(MapMessage.TurfAddDecal);

            message.Write(WorldPosition.X);
            message.Write(WorldPosition.Y);
            message.Write((byte)type);
            map.SendMessage(message);
        }
示例#12
0
文件: TileSet.cs 项目: wiltaylor/LD36
        public Sprite GetDecal(DecalType type)
        {
            switch (type)
            {
            case DecalType.Tree:
                return(_tree[0]);

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
示例#13
0
        void Init()
        {
            SkiMesh = GetComponent <SkinnedMeshRenderer>();
            MFilter = GetComponent <MeshFilter>();

            if (SkiMesh != null)
            {
                SkiMesh.sharedMesh.MarkDynamic();
                decType = DecalType.Skinned;
            }
            else if (MFilter != null)
            {
                vertices  = MFilter.sharedMesh.vertices;
                triangles = MFilter.sharedMesh.GetTriangles(0);
                decType   = DecalType.Static;
            }
        }
示例#14
0
文件: Decal.cs 项目: bmjoy/MeshDecals
        public void Init(DecalDefinition decalDef, DecalType decType, GameObject affectedObj)
        {
            decalT = decType;
            if (decalT == DecalType.Skinned)
            {
                smr = gameObject.AddComponent <SkinnedMeshRenderer>();
                if (affectedObj)
                {
                    smr.rootBone       = affectedObj.GetComponent <SkinnedMeshRenderer>().rootBone;
                    smr.bones          = affectedObj.GetComponent <SkinnedMeshRenderer>().bones;
                    smr.sharedMaterial = decalDef.material;
                }
            }
            else
            {
                mf = gameObject.AddComponent <MeshFilter>();
                mr = gameObject.AddComponent <MeshRenderer>();
                mr.sharedMaterial = decalDef.material;
            }

            oldScale        = transform.localScale;
            decalDefinition = decalDef;
            SetScale(decalDefinition.size);
        }
示例#15
0
        public static void SetUp(DecalType decType, GameObject targetObj, ref Vector3[] verts, ref int[] tris, DecalDefinition decalDef, Vector3 dir, Vector3 p, float si, float ang, float normFac, float pBack, float de)
        {
            // builder vars
            affectedObject      = targetObj;
            vertices            = verts;
            triangles           = tris;
            direction           = dir;
            point               = p;
            size                = si;
            angle               = ang;
            normalFactor        = normFac;
            pointBackwardOffset = pBack;
            depth               = de;

            // create decal GO
            GameObject decalGO = new GameObject("decalSkinned");

            decalGO.transform.parent = affectedObject.transform;

            // create decal component
            decal = decalGO.AddComponent <Decal>();
            decal.Init(decalDef, decType, affectedObject);

            if (decType == DecalType.Skinned)
            {
                CalculateMatrixAndPlanes();
                decalGO.transform.localPosition = Vector3.zero;
                decalGO.transform.localRotation = Quaternion.identity;
                decalGO.transform.localScale    = Vector3.one;
            }
            else
            {
                decalGO.transform.position = point;
                decalGO.transform.rotation = Quaternion.LookRotation(direction, Vector3.up) * Quaternion.Euler(0, 0, angle);
            }
        }
示例#16
0
        public static IDecal Get(DecalType type)
        {
            IDecal dec = null;
            switch (type)
            {
                case DecalType.Grass:
                    dec = new AnimatedDecal
                        {
                            Animation = GrassAnimation,
                            Color = new Vector3(.2f, 0.5f, 0.0f),
                            RelativePosition = new Vector3(0, .5f, 0),
                        };
                break;

            }
            return dec;
        }
示例#17
0
 public void SpawnDecalOnSurface(DecalType decalType, Vector3 position, GameObject obj)
 {
 }
    public void init(DecalType type, float targetSize = 1.0f, bool isPlayerSide = true, bool startNow = true, float timer = -1.0f)
    {
        _isPlayer = isPlayerSide;

        state = State.Start;

        skillExeType = -1;

        didStartEffect = false;
        _type          = type;
        _alpha         = 0.1f;

        if (type == DecalType.Circle)
        {
            sprite.SetSprite(CIRCLE_NAME);
            _vSize          = sprite.scale;
            _vSize.x        = 0.1f;
            _vSize.y        = 0.1f;
            sprite.scale    = _vSize;
            rotater.enabled = true;            //(targetSize <= 2.0f);

            setColorByChargingLevel(0);
            _c = sprite.color;
        }
        else if (type == DecalType.Arrow)
        {
            sprite.SetSprite(ARROW_NAME);
            _vSize          = sprite.scale;
            _vSize.x        = 1.0f;
            _vSize.y        = 1.0f;
            sprite.scale    = _vSize;
            rotater.enabled = false;

            setColorByChargingLevel(0);
            _c = sprite.color;
        }
        else if (type == DecalType.Monster)
        {
            sprite.SetSprite(MONSTER_NAME);
            _vSize          = sprite.scale;
            _vSize.x        = 1.0f;
            _vSize.y        = 1.0f;
            sprite.scale    = _vSize;
            rotater.enabled = true;
            setColor(Color.red);
            _c = sprite.color;
        }
        if (type == DecalType.DeadZone)
        {
            /*
             * sprite.SetSprite(CIRCLE_NAME);
             * _vSize = sprite.scale;
             * _vSize.x = _targetSize;
             * _vSize.y = _targetSize;
             * sprite.scale = _vSize;
             * rotater.enabled = true;//(targetSize <= 2.0f);
             * setColor(Color.red);
             * _c = sprite.color;
             */
        }

        if (isPlayerSide)
        {
            _c.a = _alpha;

            _v.x = 90.0f;
            _v.y = 0.0f;
            _v.z = 0.0f;
        }
        else
        {
            _c.a = _alpha;

            _v.x = 90.0f;
            _v.y = 180.0f;
            _v.z = 0.0f;
        }


        _q.eulerAngles = _v;
        if (ignoreAngle == false)
        {
            transform.localRotation = _q;
        }

        if (sprite != null)
        {
            sprite.color = _c;
        }
        _targetSize = targetSize;
        ++_decalIndex;

        _alphaOffset     = 0.9f / (TOTAL_EFFECT_TIME / EFFECT_TIME_OFFSET);
        _fadeAlphaOffset = _alphaOffset * 1.5f;
        _targetOffset    = (_targetSize - 0.1f) / (TOTAL_EFFECT_TIME / EFFECT_TIME_OFFSET);

        if (startNow)
        {
            startDecalEffect();
        }


        _isDecreaseSpinningSpeedType = (timer > 0);
        _decreaseSpinningDuration    = timer;
        _progressTime = 0.0f;
    }
示例#19
0
 public void AddDecal(DecalType type)
 {
     switch (type)
     {
         case DecalType.Blood:
             string decalname;
             switch (_random.Next(1, 4))
             {
                 case 1:
                     decalname = "spatter_decal";
                     break;
                 case 2:
                     decalname = "spatter_decal2";
                     break;
                 case 3:
                     decalname = "spatter_decal3";
                     break;
                 default:
                     decalname = "spatter_decal4";
                     break;
             }
             decals.Add(new TileDecal(_resourceManager.GetSprite(decalname),
                                      new Vector2D(_random.Next(0, 64), _random.Next(0, 64)), this,
                                      Color.FromArgb(165, 6, 6)));
             break;
     }
 }
示例#20
0
 public void AddDecal(DecalType type)
 {
     NetOutgoingMessage message = map.CreateMapMessage(MapMessage.TurfAddDecal);
     message.Write(WorldPosition.X);
     message.Write(WorldPosition.Y);
     message.Write((byte) type);
     map.SendMessage(message);
 }
示例#21
0
 public DecalState(Events.SpawnEvent e, DecalType type) : base(e)
 {
     DecalType = type;
 }
示例#22
0
    // Will create and configure a decal and particle based on given RaycastHit and DecalMaterial information from the hit object.
    private void CreateDecal(RaycastHit raycastHit, DecalMaterial hitMaterial, DecalType decalType)
    {
        // Calculate the position and rotation for this decal based on the RaycastHit.
        Vector3    decalOffset   = raycastHit.point + (raycastHit.normal * 0.002f);
        Quaternion decalRotation = Quaternion.FromToRotation(Vector3.up, raycastHit.normal);

        Decal targetDecal    = new Decal();
        Decal targetParticle = new Decal();

        int randomIndex = 0;

        switch (decalType)
        {
        case DecalType.Entry:
            if (hitMaterial.entryDecals.Count > 0)
            {
                randomIndex = UnityEngine.Random.Range(0, hitMaterial.entryDecals.Count);
                targetDecal = hitMaterial.entryDecals[randomIndex];
            }

            if (hitMaterial.entryParticles.Count > 0)
            {
                randomIndex    = UnityEngine.Random.Range(0, hitMaterial.entryParticles.Count);
                targetParticle = hitMaterial.entryParticles[randomIndex];
            }
            break;

        case DecalType.Exit:
            if (hitMaterial.exitDecals.Count > 0)
            {
                randomIndex = UnityEngine.Random.Range(0, hitMaterial.exitDecals.Count);
                targetDecal = hitMaterial.exitDecals[randomIndex];
            }

            if (hitMaterial.exitParticles.Count > 0)
            {
                randomIndex    = UnityEngine.Random.Range(0, hitMaterial.exitParticles.Count);
                targetParticle = hitMaterial.exitParticles[randomIndex];
            }
            break;

        case DecalType.Splatter:
            if (hitMaterial.splatterDecals.Count > 0)
            {
                randomIndex = UnityEngine.Random.Range(0, hitMaterial.splatterDecals.Count);
                targetDecal = hitMaterial.splatterDecals[randomIndex];
            }
            break;
        }

        // Create the decal.
        if (targetDecal.decalObject != null)
        {
            GameObject decal = Instantiate(targetDecal.decalObject, decalOffset, decalRotation) as GameObject;

            decal.transform.parent = raycastHit.transform;
            decal.name             = decalType + " Decal";

            Destroy(decal, targetDecal.duration);
        }

        if (targetParticle.decalObject != null)
        {
            // If there is a particle, then create it and destroy it in a second.
            Destroy(Instantiate(targetParticle.decalObject, decalOffset, decalRotation), targetParticle.duration);
        }
    }