Esempio n. 1
0
        public void Update(int filterIndex, Selection selection, float deltaTime)
        {
            switch (filterIndex)
            {
            case 0:
                isNewFrame = selection.First().GetComp <C_FrameIndex>().newFrame;
                break;

            case 1:
                if (!isNewFrame)
                {
                    return;
                }

                if (lastRay == null)
                {
                    return;
                }

                Ray ray = lastRay.Value;

                foreach (var s in selection)
                {
                    C_Collider c = s.GetComp <C_Collider>();
                    if (Vector3.ProjectOnPlane(s.GetPosition().ToVec3() - ray.origin, ray.direction).sqrMagnitude <= c.threshold * c.threshold)
                    {
                        s.AddComp <C_ClickEvent>();
                    }
                }

                lastRay = null;

                break;
            }
        }
Esempio n. 2
0
        public void Setup(Entity e, Context context)
        {
            e.AddComp <C_Position>();
            e.AddComp <C_Rotation>();

            C_Collider collider = e.AddComp <C_Collider>();

            collider.threshold = 0.15f;

            e.AddComp <C_ClickToBuild>();

            e.AddComp <C_Renderer>();

            C_Asset asset = e.AddComp <C_Asset>();

            asset.mesh     = "Mesh/TowerSlot";
            asset.material = "Materials/Default";
        }