Пример #1
0
 private void Awake()
 {
     instance              = this;
     _lineRenderer         = GetComponent <LineRenderer>();
     _animator             = GetComponent <Animator>();
     _animationHashSuccess = Animator.StringToHash("Success");
 }
Пример #2
0
        public NormalsDecorator(Device device)
        {
            _device = device;

            _lineVertexDeclaration = new VertexDeclaration(_device, VertexPositionColor.VertexElements);

            _lineEffect = new LineEffect(device);

            _normals = new Dictionary <ModelMesh, NormalBuffers>();
        }
Пример #3
0
    void UpdateAllShots(int count, List <RaycastHit> hits)
    {
        for (int i = 0; i < count; i++)
        {
            int        r        = readyShotsIndex[i];
            Shot       shot     = allShots[r];
            RaycastHit hit      = hits[i];
            Collider   collider = hits[i].collider;

            if (collider != null)
            {
                if (collider.tag == "Enemy")
                {
                    Vector3 inDir = -(shot.lastHit.point - hit.point).normalized;

                    if (collider.tag == "Enemy" && !shot.isFirst)
                    {
                        Health h = collider.GetComponent <Health>();
                        if (h.alive)
                        {
                            h.Damage(shot.damage + .25f * (shot.allHits.Count - 1));
                        }
                        else
                        {
                            collider.GetComponent <Rigidbody>().AddForceAtPosition(inDir * shot.damage, hit.point, ForceMode.Impulse);
                        }
                    }
                }
                // register the hit in the shot
                shot.Hit(hit);
                // activates an impact effect and cycles it in its queue
                impactEffects.Enqueue(impactEffects.Dequeue().Activate(hits[i].point, hits[i].normal));
            }
            else
            {
                shot.completed = true;
            }

            if (activeShotLines.ContainsKey(shot))
            {
                Console.WriteLine("Updated shot line");
                activeShotLines[shot].Activate(shot.getAllHitPoints().ToArray(), shot.completed);
                RequeueLine(activeShotLines[shot]);
            }
            else
            {
                Console.WriteLine("Used new shot line");
                // fetches a new line from the list,
                LineEffect newLine = lineEffects.Dequeue();
                activeShotLines.Add(shot, newLine);
                newLine.Activate(shot.getAllHitPoints().ToArray(), shot.completed);
                lineEffects.Enqueue(newLine);
            }
        }
    }
        void Start()
        {
            mTrackableBehaviour = GetComponent <TrackableBehaviour>();
            if (mTrackableBehaviour)
            {
                mTrackableBehaviour.RegisterTrackableEventHandler(this);
            }


            LineEffect.SetActive(true);
            GetComponentInChildren <Canvas> ().enabled = false;
        }
Пример #5
0
    void lineRemoveRunning(EffectBasic eb)
    {
        LineEffect lineEF = (LineEffect)eb;
        float      rate   = (float)eb.nowTime / (float)eb.runningTime;
        //计算当前位置并调整之
        LineRenderer LineRenderer = lineEF.selfGO.GetComponent <LineRenderer>();
        Vector3      nPos         = (lineEF.eGO.transform.position - lineEF.sGO.transform.position) * rate + lineEF.sGO.transform.position;

        LineRenderer.SetPosition(0, nPos);
        //调整子对象中的粒子发射器位置,使其与终点相同
        nPos.z = -5;
        lineEF.selfGO.GetComponentInChildren <ParticleSystem>().transform.position = nPos;
    }
Пример #6
0
 public override void UpdateCom()
 {
     base.UpdateCom();
     if (!isFirstUpdate)
     {
         trail = new TrailUpdater(transform, distanceRatio);
         line  = StageManager.Instance.LineFactory.CreateLine(
             Color.white, lifeTime,
             trail,
             new GradientUpdater(gradient)
             );
         isFirstUpdate = true;
     }
 }
Пример #7
0
            internal static bool Prefix(LineEffect __instance)
            {
                if (__instance.rotateToPointer?.dartlingMaintainLastPos?.tower != null)
                {
                    if (__instance.rotateToPointer.dartlingMaintainLastPos.tower.targetType.intID != -1 &&
                        __instance.rotateToPointer.attack.target.bloon != null &&
                        !__instance.lineEffectModel.isLineDisplayEndless)
                    {
                        __instance.targetMagnitude =
                            __instance.rotateToPointer.attack.target.bloon.Position.Distance(__instance.rotateToPointer
                                                                                             .dartlingMaintainLastPos.tower.Position) - 20;
                    }
                }

                return(true);
            }
Пример #8
0
    /// <summary>
    /// 消去路径的特效
    /// </summary>
    /// <param name="l"></param>
    /// <param name="delay"></param>
    /// <param name="time"></param>
    public void RemoveLineAnimation(GameObject sGO, GameObject eGO, GameObject line, int delay, int time, bool isPara = false)
    {
        LineEffect lineEffect = new LineEffect(delay, time, EFType.LineEffect, sGO, eGO, line);

        lineEffect.EFStart   += nothing;
        lineEffect.EFEnd     += lineRemoveEnd;
        lineEffect.EFRunning += lineRemoveRunning;
        if (!isPara)
        {
            efList.Add(lineEffect);
        }
        else
        {
            efListPara.Add(lineEffect);
        }
    }
Пример #9
0
    /// <summary>
    /// 新建一个线特效
    /// </summary>
    /// <param name="sGO"></param>
    /// <param name="eGO"></param>
    /// <param name="line"></param>
    /// <param name="delay"></param>
    /// <param name="time"></param>
    public void NewLineCreatAnimation(GameObject sGO, GameObject eGO, GameObject line, int delay, int time, bool isPara = false)
    {
        line.GetComponent <LineRenderer>().SetPosition(0, sGO.transform.position);
        line.GetComponent <LineRenderer>().SetPosition(1, sGO.transform.position);
        LineEffect lineEffect = new LineEffect(delay, time, EFType.LineEffect, sGO, eGO, line);

        lineEffect.EFStart   += lineCreateStart;
        lineEffect.EFEnd     += lineCreateEnd;
        lineEffect.EFRunning += lineCreateRunning;
        if (!isPara)
        {
            efList.Add(lineEffect);
        }
        else
        {
            efListPara.Add(lineEffect);
        }
    }
Пример #10
0
    private void Shoot(IWeaponArgsHolder holder)
    {
        if (!gameObject.activeInHierarchy)
        {
            return;
        }

        if (bulletSupply == null)
        {
            bulletSupply = holder.GetAmmoSupply();
        }

        UpdateAmmo();
        WaitCD();

        if (ammoItems.Count <= 0)
        {
            return;
        }

        WeaponArgs weaponArgs = holder.GetWeaponArgs();

        ammoItems.Peek().Item.Amount--;

        for (int i = 0; i < numOfProjectiles; i++)
        {
            float x = Random.Range(-inAccuracy, inAccuracy) / 150;
            float y = Random.Range(-inAccuracy, inAccuracy) / 150;

            Vector2 offset       = new Vector2(x, y);
            Vector2 newDirection = (Vector2)weaponArgs.ray.direction + offset;

            WeaponArgs shootArgs         = new WeaponArgs(new Ray(weaponArgs.ray.origin, newDirection), mask, weaponArgs.objectsToIgnore);
            LineEffect createdLineEffect = lineEffectPool.Instantiate(transform.position, Quaternion.identity);
            createdLineEffect.Setup(firePoint.position, shootArgs.hit.point, lineColor, lineWidth, lineLifeTime);

            shootArgs.HitDamageable?.Damage(damage);
        }
    }
Пример #11
0
    void ProcessLines()
    {
        List <SpeechLine> currentLines = new List <SpeechLine>();
        string            speaker      = "";

        foreach (string line in rawTextArray)
        {
            if (string.IsNullOrEmpty(line))
            {
                continue;
            }                                             // skip line if it's empty

            string processedLine = line;
            if (line.IndexOf("//") > -1)
            {
                processedLine = line.Substring(0, line.IndexOf("//"));
            }                                                                                       // remove comments

            bool isSpeakingLine = true;

            if (processedLine.IndexOf(':') > -1) // determine speaker OR effect
            {
                string preText = processedLine.Substring(0, processedLine.IndexOf(':'));
                processedLine = processedLine.Remove(0, processedLine.IndexOf(':') + 1); // remove pretext from the line
                preText       = preText.Replace(":", string.Empty);

                // process preText
                if (!string.IsNullOrEmpty(preText))
                {
                    // if this line has pretext, save and clear the previous line(s)
                    if (currentLines.Count > 0)
                    {
                        lines.Add(currentLines);
                    }                                       // add prev if it had anything
                    currentLines = new List <SpeechLine>(); // clear and make a new instance

                    switch (preText)                        // check if pretext is a tag
                    {
                    case "EFFECTS":                         // if this is an interaction effect, add it to the list
                        string[] effectTags = processedLine.Split(' ');
                        foreach (string str in effectTags)
                        {
                            interactionEffects.Add(str);
                        }
                        isSpeakingLine = false;
                        break;

                    // add more cases as needed

                    default:     // default: if it's not an effect, then this is a name
                        speaker        = preText;
                        isSpeakingLine = true;
                        break;
                    }
                }
            }

            if (!isSpeakingLine || string.IsNullOrEmpty(processedLine))
            {
                continue;
            }
            else //continue processing if this is a speaker line
            {
                int        optionNum    = -1; // defaults to -1 if no branching
                string     lineText     = "";
                string     synopsisText = "";
                LineEffect lineEffect   = (LineEffect)0;
                bool       isBranching  = false;

                // check if this is a branching line
                if (processedLine.Contains("~"))
                {
                    isBranching = true;
                    string[] branches = processedLine.Split('~');
                    foreach (string option in branches)
                    {
                        if (!string.IsNullOrEmpty(option))
                        {
                            // get option number (and remove it from the rest of the string)
                            optionNum = Int32.Parse(option.Substring(0, option.IndexOf(" ")));
                            lineText  = option.Remove(0, option.IndexOf(" ")); // remove the number in the beginning

                            // process the synopsis text (and remove it)
                            if (lineText.IndexOf('%') != -1)
                            {
                                synopsisText = lineText.Substring(lineText.IndexOf('%') + 1, lineText.LastIndexOf('%') - lineText.IndexOf('%') - 1);
                                lineText     = lineText.Remove(lineText.IndexOf('%'), lineText.LastIndexOf('%') - lineText.IndexOf('%') + 1);
                            }

                            // process lines
                            processedLine = ProcessSpeech(lineText, ref lineEffect);
                        }
                    }
                }
                else //non-branching: process normally
                {
                    // process lines
                    processedLine = ProcessSpeech(processedLine, ref lineEffect);
                }

                // after processing is complete, make a SpeechLine & add it
                SpeechLine lineToAdd = new SpeechLine()
                {
                    speakerName  = speaker,
                    synopsisText = synopsisText,
                    lineText     = processedLine,
                    lineEffect   = lineEffect,
                    isBranch     = isBranching,
                    optionNum    = optionNum
                };

                currentLines.Add(lineToAdd);
            }
        }

        // add the last line
        if (currentLines.Count > 0)
        {
            lines.Add(currentLines);
        }
    }
Пример #12
0
    string ProcessSpeech(string lineText, ref LineEffect lineEffect)
    {
        // process and format TMP font sizes
        // process font increases
        while (lineText.IndexOf("<<") > 0) // keep processing until there are no more increases
        {
            int indexOfLastBracket = lineText.IndexOf(">>");
            while ((indexOfLastBracket + 1) < lineText.Length && lineText[indexOfLastBracket + 1] == '>')
            {
                indexOfLastBracket++;
            }

            string stringToReplace = lineText.Substring(lineText.IndexOf("<<"), indexOfLastBracket - lineText.IndexOf("<<") + 1);
            string stringToFormat  = stringToReplace;
            int    timesToInc      = stringToFormat.Split('<').Length;                             // counts how many brackets: if there is none, this should be 1(?)
            stringToFormat = stringToFormat.Replace("<", string.Empty).Replace(">", string.Empty); //clean the string of << and >> characters

            stringToFormat = "<size=" + (100 + (10 * timesToInc)).ToString() + "%>" + stringToFormat + "<size=100%>";
            lineText       = lineText.Replace(stringToReplace, stringToFormat);
        }

        // process font decreases
        while (lineText.IndexOf("[[") > 0) // keep processing until there are no more decreases
        {
            int indexOfLastBracket = lineText.IndexOf("]]");
            while ((indexOfLastBracket + 1) < lineText.Length && lineText[indexOfLastBracket + 1] == ']')
            {
                indexOfLastBracket++;
            }

            string stringToReplace = lineText.Substring(lineText.IndexOf("[["), indexOfLastBracket - lineText.IndexOf("[[") + 1);
            string stringToFormat  = stringToReplace;
            int    timesToInc      = stringToFormat.Split('[').Length;                             // counts how many brackets: if there is none, this should be 1(?)
            stringToFormat = stringToFormat.Replace("[", string.Empty).Replace("]", string.Empty); //clean the string of << and >> characters

            stringToFormat = "<size=" + (100 - (10 * timesToInc)).ToString() + "%>" + stringToFormat + "<size=100%>";
            lineText       = lineText.Replace(stringToReplace, stringToFormat);
        }

        // process bolding
        while (lineText.IndexOf("**") > 0) // keep processing until there are no more
        {
            int indexOpen = lineText.IndexOf("**");

            string stringToFormat = lineText.Substring(indexOpen + 2);
            int    indexClose     = stringToFormat.IndexOf("**");  // get next index of **
            stringToFormat = stringToFormat.Substring(0, indexClose + 2);
            stringToFormat = stringToFormat.Replace("**", "</b>"); // replace the closing with </b>
            stringToFormat = "<b>" + stringToFormat;               // replace the opening with <b>

            string stringToReplace = lineText.Substring(indexOpen, indexClose + 4);

            lineText = lineText.Replace(stringToReplace, stringToFormat);
        }

        // process italics
        while (lineText.IndexOf("*") > 0) // keep processing until there are no more
        {
            int indexOpen = lineText.IndexOf("*");

            string stringToFormat = lineText.Substring(indexOpen + 1);
            int    indexClose     = stringToFormat.IndexOf("*");  // get next index of *
            stringToFormat = stringToFormat.Substring(0, indexClose + 1);
            stringToFormat = stringToFormat.Replace("*", "</i>"); // replace the closing with </i>
            stringToFormat = "<i>" + stringToFormat;              // replace the opening with <i>

            string stringToReplace = lineText.Substring(indexOpen, indexClose + 2);

            lineText = lineText.Replace(stringToReplace, stringToFormat);
        }

        // process any hex codes
        while (lineText.IndexOf("|#") > 0) // keep processing until there are no more hex codes
        {
            int    indexOpen = lineText.IndexOf("|#");
            string hexCode   = lineText.Substring(indexOpen + 1, 7);

            string stringToFormat = lineText.Substring(indexOpen + 2 + 6);                    // 2 for |# and 6 more for the hex code
            int    indexClose     = stringToFormat.IndexOf("|");                              // get next index of |
            stringToFormat = stringToFormat.Substring(0, indexClose + 1);
            stringToFormat = stringToFormat.Replace("|", "<color=" + defaultTextColor + ">"); // replace the closing with </i>
            stringToFormat = "<color=" + hexCode + ">" + stringToFormat;                      // replace the opening with <i>

            string stringToReplace = lineText.Substring(indexOpen, indexClose + 2 + 6 + 1);

            lineText = lineText.Replace(stringToReplace, stringToFormat);
        }

        // process any line effects
        if (lineText.IndexOf('[') > -1)
        {
            string lineEffectStr = lineText.Substring(lineText.IndexOf('[') + 1, lineText.IndexOf(']') - lineText.IndexOf('[') - 1);
            lineEffect = stringToLineEffect(lineEffectStr);
            lineText   = lineText.Remove(lineText.IndexOf('['), lineText.IndexOf(']') - lineText.IndexOf('[') + 1);
        }

        // remove extra whitespace
        lineText = lineText.Trim(' ');

        //Debug.Log(lineText);
        return(lineText);
    }
Пример #13
0
 public void RequeueLine(LineEffect line)
 {
     lineEffects.ToList().Remove(line);
     lineEffects.Enqueue(line);
 }
Пример #14
0
        public void Render()
        {
            if (!isRunning)
            {
                return;
            }

            Device device = this.Host.Device;

            if (device == null)
            {
                return;
            }

            device.InputAssembler.InputLayout       = this.ParticleLayout;
            device.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleStrip;

            ParticlePass.Apply();

            device.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(this.Particles, 32, 0));
            ParticleProjection.Set(new Vector2(Host.Width, Host.Height));
            ParticleCamera.Set(new Vector2(0, -PlayerShip.Instance.Position.Y));
            device.Draw(ParticleManager.particleList.Count, 0);

            device.InputAssembler.InputLayout       = this.ShapeLayout;
            device.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleStrip;

            ShapeCamera.Set(new Vector2(0, -PlayerShip.Instance.Position.Y));
            ShapeProjection.Set(new Vector2(Host.Width, Host.Height));

            foreach (Entity entity in EntityManager.Entities)
            {
                device.InputAssembler.SetVertexBuffers(0, entity.Shape.Buffer);

                ShapeColor.Set(entity.Color);
                ShapePosition.Set(new Vector3(entity.Position, entity.Orientation));

                ShapePass.Apply();
                device.Draw(entity.Shape.Vertices.Length * 2 + 2, 0);
            }

            if (Math.Abs(Profiles.Current.State.LinesPosition - PlayerShip.Instance.Position.Y) < Height)
            {
                device.InputAssembler.InputLayout       = this.LineLayout;
                device.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.PointList;

                device.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(LineBuffer, 8, 0));

                LineEffect.GetVariableByName("Step").AsScalar().Set(0.1f);
                LineEffect.GetVariableByName("Width").AsScalar().Set(2.0f / Width);
                LineEffect.GetVariableByName("Height").AsScalar().Set(1.0f - Math.Abs(Profiles.Current.State.LinesPosition - PlayerShip.Instance.Position.Y) / Height);
                LineEffect.GetVariableByName("Color").AsVector().Set(Color.Yellow);

                Vector4[] disturb = new Vector4[16];
                float     maxX = 0.05f, maxY = 0.02f;

                for (int i = 0; i < linesCount; i++)
                {
                    for (int k = 0; k < 16; k++)
                    {
                        disturb[k] = new Vector4(Rand.NextFloat(-maxX, maxX), Rand.NextFloat(-maxY, maxY), Rand.NextFloat(-maxX, maxX), Rand.NextFloat(-maxY, maxY));
                    }
                    LineEffect.GetVariableByName("Disturb").AsVector().Set(disturb);
                    LineEffect.GetTechniqueByIndex(0).GetPassByIndex(0).Apply();

                    device.Draw(1, i);
                }
            }
        }