Ejemplo n.º 1
0
    /// <summary>
    /// LaunchProjectile method implemented by IProjectile
    /// This target can be a HitPoint from a raycast or a point on the line from the player to the
    /// Camera.trasnform.forward (i.e. is the raycast does not intercept an entity)
    /// After that, we instantiate a Projectile, make it look at the target
    /// Apply a force to it and launch the particle system associated to the prefab (if exists)
    /// </summary>
    public virtual void LaunchProjectile()
    {
        Camera     cameraPlayer = launcher.GetComponentInChildren <Camera>();
        Vector3    target;
        RaycastHit hit;

        bool hasFoundHitPoint = Physics.Raycast(PosHelper.GetOriginOfDetector(launcher), cameraPlayer.transform.forward,
                                                out hit, Mathf.Infinity, Physics.DefaultRaycastLayers, QueryTriggerInteraction.Ignore);

        if (hasFoundHitPoint)
        {
            target = hit.point;
        }
        else
        {
            target = transform.position + cameraPlayer.transform.forward * 10;
        }

        transform.LookAt(target);
        GetComponent <Rigidbody>().AddForce(transform.forward * projectileSpeed);
        ParticleSystem particles = GetComponent <ParticleSystem>();

        if (particles != null)
        {
            particles.Play();
        }
    }
Ejemplo n.º 2
0
 protected override void Start()
 {
     _cameraPlayer      = this.GetComponentInChildren <Camera>();
     _launcherTransform = PosHelper.GetRightHandTransformOfPlayer(transform);
     _throwable         = LoadResource("Trident");
     base.Start();
 }
Ejemplo n.º 3
0
    /** LaunchSpell : public override void Method
     * The LauncheSpell Method is called by the abstract Class Classe when the player press the key associated to the spell.
     * First at all, we launch the mother method to initialize the spell launching. If the spell is Launcheable, we find a target point for our projectile.
     * If the RayCast does not intercept a collider, the spell can not be launched.
     * After that, we instantiate a fireball, make it look at the target, apply a force to it and launche the particle system associated to the prefab.
     * The particularity of this instantiation is that the fireball appears on a circle in the sky at random coords, upper the target Point.
     * Finally, we call the OnSpellLaunched method in the mother class.
     **/
    public override void LaunchSpell()
    {
        if (!IsSpellLauncheable())
        {
            return;
        }

        RaycastHit hit;
        bool       hasFoundHitPoint = Physics.Raycast(PosHelper.GetOriginOfDetector(transform), _cameraPlayer.transform.forward, out hit, Mathf.Infinity, Physics.DefaultRaycastLayers, QueryTriggerInteraction.Ignore);

        if (hasFoundHitPoint)
        {
            base.LaunchSpell();
            TargetOfSolarBurn = hit.point;
        }
        else
        {
            return;
        }

        Vector2 pointInCircle = Random.insideUnitCircle.normalized * 8;

        Vector3 v = new Vector3(TargetOfSolarBurn.x + pointInCircle.x, TargetOfSolarBurn.y + 15, TargetOfSolarBurn.z + pointInCircle.y);

        Instantiate(throwable, v, new Quaternion(), this.transform);

        base.OnSpellLaunched();
    }
Ejemplo n.º 4
0
    /** Start : protected override void Method
     * First at all, we override the GCD of the mother class.
     * Then we get the prefab of the AutoAttackFireMage.
     * Then, the scripts is looking for the origin point of the instantiation (i.e. the hand of our character).
     **/
    protected override void Start()
    {
        _cameraPlayer      = this.GetComponentInChildren <Camera>();
        _throwable         = LoadResource("AutoAttackFireMage");
        _shieldObject      = LoadResource("FireMageShield");
        _launcherTransform = PosHelper.GetRightHandTransformOfPlayer(transform);

        base.Start();
    }
Ejemplo n.º 5
0
        private void DoLogin(string scanCode)
        {
            Employee employee = EmployeeManager.LookupByScanCode(scanCode);

            if (employee == null)
            {
                // The debug version will have an exception here if escape-exit is used
                try
                {
                    PosDialogWindow.ShowDialog(Types.Strings.LoginLoginIncorrect, Types.Strings.Error);
                    return;
                }
                catch
                {
                    return;
                }
            }

            // Check if logged-in somewhere else
            if (PosHelper.IsLocked(TableName.Employee, employee.Id))
            {
#if !DEMO
                BroadcastClientSocket.SendRemoteLogout(employee.Id);
#endif
                PosHelper.Unlock(TableName.Employee, employee.Id);
            }

            // Check if clock-in is required
            if (!employee.IsClockedIn())
            {
                if (!DoClockIn(employee) && !employee.HasPermission(Permissions.SystemMaintenance))
                {
                    return;
                }
            }

            // Proceed with login
            IsLoggedIn = true;

            // Clear dead-locks
            Lock.DeleteAllEmployeeLocks(employee.Id);

            // Lock the employee to prevent simultaneous logins
            PosHelper.Lock(TableName.Employee, employee.Id, employee.Id);

#if !DEMO
            // Tell other clients, that this employee just logged in
            BroadcastClientSocket.SendMessage("LOGIN " + employee.Id);
#endif
            StartAutoLogoutTimer();
            if (Login != null)
            {
                Login.Invoke(this, new UserLoginEventArgs(employee));
            }
        }
Ejemplo n.º 6
0
 public static void ClearTicket()
 {
     LoginControl.StartAutoLogoutTimer();
     PosHelper.Unlock(ActiveTicket);
     IsActiveTicketLocked = false;
     ActiveTicket         = null;
     ActiveItem           = null;
     ActiveCategory       = null;
     ActiveTicketItem     = null;
     PseudoEmployee       = null;
     if (TicketCleared != null)
     {
         TicketCleared.Invoke(null, new EventArgs());
     }
 }
Ejemplo n.º 7
0
    /** IsSpellLauncheable(), public override bool method
     * The solar burn spell is launcheable only on ground surfaces.
     * First we check in a Raycastall if the player is aiming at the ground.
     * If it is, and if the base.IsSpellLauncheable() is true, then you can cast the spell.
     **/
    public override bool IsSpellLauncheable()
    {
        _playerTargetingFloor = false;
        RaycastHit[] hits = Physics.RaycastAll(PosHelper.GetOriginOfDetector(transform), _cameraPlayer.transform.forward, Mathf.Infinity);
        for (int i = 0; i < hits.Length; i++)
        {
            if (hits[i].collider.gameObject.tag == "Floor" || hits[i].collider.gameObject.name == "Ground")
            {
                _playerTargetingFloor = true;
                break;
            }
        }

        return(base.IsSpellLauncheable() && _playerTargetingFloor);
    }
Ejemplo n.º 8
0
    public static Pos getClosestNode(Pos pos, List <Pos> nodes)
    {
        Pos   closestNode = null;
        float minDistance = float.MaxValue;

        foreach (Pos node in nodes)
        {
            float distance = PosHelper.getNodeDistance(pos, node);
            if (distance < minDistance)
            {
                minDistance = distance;
                closestNode = node;
            }
        }

        return(closestNode);
    }
Ejemplo n.º 9
0
        private void ApplyDiscount()
        {
            TicketDiscount result = null;

            FormattedListBoxItem selectedItem =
                (FormattedListBoxItem)listBoxAvailable.SelectedItem;
            Discount discount = (Discount)selectedItem.ReferenceObject;

            bool hasPermission = (!discount.RequiresPermission ||
                                  SessionManager.ActiveEmployee.HasPermission(Permissions.RegisterDiscounts));

            if (!hasPermission &&
                (PosHelper.GetPermission(Permissions.RegisterDiscounts) == null))
            {
                PosDialogWindow.ShowDialog(
                    Types.Strings.YouDoNotHavePermissionToApplyThisDiscount,
                    Types.Strings.PermissionDenied);
                return;
            }

            if (discount.Amount == null)
            {
                double?amount = discount.AmountIsPercentage ?
                                PosDialogWindow.PromptPercentage(this, Types.Strings.EnterDiscountPercentage, null) :
                                PosDialogWindow.PromptNumber(Types.Strings.EnterDiscountAmount, (double?)null);
                if (amount != null)
                {
                    result = TicketDiscount.Add(discount.Id, SelectedTicket.PrimaryKey,
                                                amount.Value, SessionManager.PseudoEmployeeId);
                }
            }
            else
            {
                result = TicketDiscount.Add(discount.Id, SelectedTicket.PrimaryKey,
                                            null, SessionManager.PseudoEmployeeId);
            }

            if (result != null)
            {
                listBoxAvailable.SelectedItem = null;
                listBoxAvailable.Items.Remove(selectedItem);

                listBoxApplied.Items.Add(selectedItem);
                listBoxApplied.SelectedItem = selectedItem;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Returns true if the given face of the voxel at the given position is solid
        /// </summary>
        /// <param name="objPos">The position to check</param>
        /// <param name="dir">The face to check</param>
        /// <returns></returns>
        public bool IsSolid(IntVector3 objPos, OrdinalDirections dir)
        {
            if (!IsInObjectBoundary(objPos))
            {
                return(false);
            }

            IntVector3 chunkPos = PosHelper.ObjectToChunkPosition(objPos);

            if (!IsChunkLoaded(chunkPos))
            {
                return(false);
            }
            else
            {
                return(loadedChunks[chunkPos].IsSolid(PosHelper.ObjectToLocalPosition(objPos), dir));
            }
        }
Ejemplo n.º 11
0
    private static Tuple3 <Pos, WayReference, Vector3> GetHumanSpawnInfo(long nodeId)
    {
        Pos spawnPos = nodes [nodeId];
        // Position to spawn/despawn
        Pos          spawnNode;
        WayReference closestWay   = null;
        Vector3      closestPoint = Vector3.zero;

        if (NodeIndex.nodeWayWalkPathIndex.ContainsKey(spawnPos.Id))
        {
            // Spawn in a node
            spawnNode    = spawnPos;
            closestWay   = NodeIndex.nodeWayWalkPathIndex [spawnPos.Id] [0];
            closestPoint = Game.getCameraPosition(spawnNode);
        }
        else
        {
            // Calculate which node is closest
            spawnNode = PosHelper.getClosestNode(spawnPos, NodeIndex.walkNodes);
            // Pick closest wayReference
            Vector3             spawnPosVector  = Game.getCameraPosition(spawnPos);
            float               closestDistance = float.MaxValue;
            List <WayReference> ways            = NodeIndex.nodeWayIndex [spawnNode.Id];
            foreach (WayReference way in ways)
            {
                Vector3 wayStart       = Game.getCameraPosition(way.node1);
                Vector3 wayEnd         = Game.getCameraPosition(way.node2);
                Vector3 projectedPoint = Math3d.ProjectPointOnLineSegment(wayStart, wayEnd, spawnPosVector);
                float   distance       = PosHelper.getVectorDistance(spawnPosVector, projectedPoint);
                if (distance < closestDistance)
                {
                    closestDistance = distance;
                    closestWay      = way;
                    closestPoint    = projectedPoint;
                }
            }
//			DebugFn.arrow (spawnPosVector, closestPoint);
        }
//		DebugFn.square (closestPoint);

        return(Tuple3.New(spawnNode, closestWay, closestPoint));
    }
Ejemplo n.º 12
0
        private void EditPartyInfo()
        {
            if (PosHelper.IsLocked(TableName.Party, CurrentTicket.PartyId))
            {
                PosDialogWindow.ShowDialog(
                    Types.Strings.ThePartyInformationForThisTicketIsCurrentlyBeingModifiedSomewhereElse,
                    Types.Strings.PartyInformationLocked);
                return;
            }
            PosHelper.Lock(TableName.Party, CurrentTicket.PartyId, SessionManager.ActiveEmployee.Id);

            PosDialogWindow  window  = PartyEditControl.CreateInDefaultWindow();
            PartyEditControl control = window.DockedControl as PartyEditControl;

            control.Initialize(ParentTicket.PartyId);
            window.ShowDialog(ParentWindow);

            control.ActiveParty.Update();
            PosHelper.Unlock(TableName.Party, CurrentTicket.PartyId);
        }
Ejemplo n.º 13
0
    public static WayReference getClosestWayReference(Vector3 point)
    {
        float               closestDistance = float.MaxValue;
        WayReference        closestWay      = null;
        List <WayReference> carWays         = allWayReferences.FindAll(wayRef => wayRef.way.CarWay);

        foreach (WayReference way in carWays)
        {
            Vector3 wayStart       = Game.getCameraPosition(way.node1);
            Vector3 wayEnd         = Game.getCameraPosition(way.node2);
            Vector3 projectedPoint = Math3d.ProjectPointOnLineSegment(wayStart, wayEnd, point);
            float   distance       = PosHelper.getVectorDistance(point, projectedPoint);
            if (distance < closestDistance)
            {
                closestDistance = distance;
                closestWay      = way;
            }
        }
        return(closestWay);
    }
Ejemplo n.º 14
0
        private void RefundTicket()
        {
            TicketRefundType?refundType = PosHelper.ConfirmRefundPrompt();

            if (refundType != null)
            {
                double refundAmount = PosHelper.RefundTicketCommand(SelectedTicket, refundType.Value);

                RegisterManager.OpenCashDrawer();

                PosDialogWindow.ShowDialog(Types.Strings.RefundedTotalIs +
                                           refundAmount.ToString("C2"), Types.Strings.RefundTotal, DialogButtons.Ok);
            }
            Window window = Window.GetWindow(this);

            if (window != null)
            {
                window.Close();
            }
        }
Ejemplo n.º 15
0
 private void buttonStartOfDay_Click(object sender, RoutedEventArgs e)
 {
     FunctionsContextMenu.IsOpen = false;
     PosHelper.StartOfDay();
 }
Ejemplo n.º 16
0
        private void RestoreToSingleTicket()
        {
            // Need to check for locks on any of the settings in the source list
            if (listboxSourceTicket.Items.Cast <FormattedListBoxItem>()
                .Where(item => item.Id != OriginalTicket.PrimaryKey.Id)
                .Any(item => PosHelper.IsLocked(TableName.Ticket, item.Id)))
            {
                PosDialogWindow.ShowDialog(
                    Types.Strings.OneOrMoreOfTheTicketsInThisPartyIsCurrentlyBeingModifiedSomewhereElseCanNotChangeToSingleTicket, Types.Strings.TicketLocked);
                return;
            }

            // Move TicketItems
            IEnumerable <Ticket> tickets = TicketManager.GetPartyTickets(ParentTicket.PartyId);

            foreach (Ticket ticket in tickets)
            {
                if (ticket.PrimaryKey.Equals(ParentTicket.PrimaryKey) ||
                    ticket.IsClosed || ticket.IsCanceled)
                {
                    continue;
                }
                // Move all ticket items that are not on the ParentTicket, back to
                // the ParentTicket
#if DEMO
                int ticketItemCount = ParentTicket.GetNumberOfTicketItems() +
                                      ticket.GetNumberOfTicketItems();
                if (ticketItemCount > 3)
                {
                    PosDialogWindow.ShowDialog(Window.GetWindow(this),
                                               Types.Strings.YouCanNotAddMoreThan3TicketItemsToASingleTicketInTheDemoVersionAdditionalTicketItemsWillBeRemoved,
                                               Types.Strings.DemoRestriction);
                }
#endif
                IEnumerable <TicketItem> ticketItems = TicketItem.GetAll(ticket.PrimaryKey);
                foreach (TicketItem ticketItem in ticketItems)
                {
#if DEMO
                    if (ParentTicket.GetNumberOfTicketItems() >= 3)
                    {
                        ticketItem.Delete();
                        continue;
                    }
#endif
                    ticketItem.SetTicketId(ParentTicket.PrimaryKey.Id);
                    ticketItem.UpdateTicketId();
                }

                // Delete the child ticket
                TicketManager.Delete(ticket.PrimaryKey);
            }

            // Delete Party Invites
            IEnumerable <PartyInvite> invites = PartyInvite.GetAll(ParentTicket.PartyId);
            foreach (PartyInvite invite in invites)
            {
                PartyInvite.Delete(invite.Id);
            }

            // Delete the party
            Party.Delete(ParentTicket.PartyId);
            ParentTicket.SetPartyId(0);
            ParentTicket.Update();
            CurrentTicket = OriginalTicket = ParentTicket;

            // Done, Close the parent window
            Window.GetWindow(this).Close();
        }
Ejemplo n.º 17
0
 private void buttonEndOfDay_Click(object sender, RoutedEventArgs e)
 {
     FunctionsContextMenu.IsOpen = false;
     PosHelper.EndOfDay();
     OrderEntryCommands.UpdateTicketDetailCommands();
 }
Ejemplo n.º 18
0
 private void buttonEndOfYear_Click(object sender, RoutedEventArgs e)
 {
     FunctionsContextMenu.IsOpen = false;
     PosHelper.EndOfYear();
 }
Ejemplo n.º 19
0
        void Current_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            e.Handled = true;

            // Stop the auto-logoof timer
            LoginControl.StopAutoLogoutTimer();

            // Close all database connections
            DataModelBase.CloseAll();

#if !DEMO
            // Send the exception to the upgrade server
            Updater.StartCrashReport(e.Exception);
#endif
            // Save the exception, serialized to the AppData folder
            try
            {
                DateTime now           = DateTime.Now;
                string   rootDirectory =
                    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
                    Path.DirectorySeparatorChar + "TemPOS";
                if (!Directory.Exists(rootDirectory))
                {
                    Directory.CreateDirectory(rootDirectory);
                }
                string path = rootDirectory + Path.DirectorySeparatorChar + "crashdata-" +
                              now.Year + now.Month.ToString("D2") + now.Day.ToString("D2") + "-" +
                              now.Hour.ToString("D2") + now.Minute.ToString("D2") + now.Second.ToString("D2") +
                              ".bin";
                using (FileStream fileStream = new FileStream(path, FileMode.CreateNew))
                {
                    byte[] serialData = e.Exception.SerializeObject();
                    using (BinaryWriter writer = new BinaryWriter(fileStream))
                    {
                        writer.Write(serialData);
                    }
                }
            }
            catch { }

            // Display the exception message
            DisplayExceptionDialog(e.Exception);

            // Remove employee table lock (that prevents simultaneous login)
            if (SessionManager.ActiveEmployee != null)
            {
                PosHelper.Unlock(TableName.Employee, SessionManager.ActiveEmployee.Id);
            }

            // Close this app
            if (_mainWindow != null)
            {
                _mainWindow.AllowClose = true;
                _mainWindow.Close();
            }

            // Disable user control crap
            if (ConfigurationManager.UseKeyboardHook)
            {
                UserControlManager.Disable();
            }

            UserControlManager.ShowTaskbar(true);
#if !DEBUG
            if (PastRestartPoint)
            {
                // Restart application
                Process.Start(Application.ResourceAssembly.Location, "/RESTART");
                App.SwitchToDefaultDesktopOnClose = false;
            }
            else
            {
                App.SwitchToDefaultDesktopOnClose = true;
            }
#else
            App.SwitchToDefaultDesktopOnClose = true;
#endif
            // Shutdown current application
            Application.Current.Shutdown();
            Process.GetCurrentProcess().Kill();
        }