Beispiel #1
0
    // allow to launch ball if:
    // finger is outside the ball
    // we initially clicked on the ball
    // I assume that exit/enter happens before up/end
    void TryToLaunchOrCancelBall()
    {
        if (m_BallUp && m_TouchEnd)
        {
            // cancel
            if (m_BallEnter)
            {
                // Debug.LogError("Cancel strike");
            } //strike
            else
            {
                m_Dir.x = m_Ball.m_RectTransform.position.x - m_CurrTouchPos.x;
                m_Dir.y = m_Ball.m_RectTransform.position.y - m_CurrTouchPos.y;

                // m_StrikeMagnitude = Mathf.Clamp(dir.magnitude, c_StrikeMagnitudeMin, c_StrikeMagnitudeMax);
                m_Ball.Strike(m_Dir.normalized, m_StrikeMagnitudeMax * GUILogic.GetScale());
            }
            ResetKeys();
        }
        // Debug.Log("m_BallDown " + m_BallDown);
        // Debug.Log("m_TouchBegin " + m_TouchBegin);
        // Debug.Log("m_BallEnter " + m_BallEnter);

        // Debug.Log("m_BallUp " + m_BallUp);
        // Debug.Log("m_TouchEnd " + m_TouchEnd);
    }
Beispiel #2
0
        public override void Initialize()
        {
            GUIFont = Game.Content.Load <SpriteFont>("font");

            camera         = new Camera2D(Game.GraphicsDevice.Viewport);
            camera.Stretch = new Vector2(
                Game.GraphicsDevice.Viewport.Width / targetResolution.X,
                Game.GraphicsDevice.Viewport.Height / targetResolution.Y
                );

            gameRenderer          = new GameRenderer(Game, gameScene, camera);
            animator              = new Animator(Game, gameScene);
            phys                  = new PhysicsBasicEngine(Game, gameScene);
            gui                   = new GUILogic(Game, camera, _userInput);
            debugRenderer         = new DebugRenderer(Game, gameScene, camera);
            debugRenderer.Visible = false;

            Game.Components.Add(phys);
            Game.Components.Add(animator);
            Game.Components.Add(gameRenderer);
            Game.Components.Add(gui);
            Game.Components.Add(debugRenderer);

            level.InitLevel(gameScene);
            createGameGui();

            UnitSpawner.Scene = gameScene;

            CopyAI ai = new CopyAI(gameScene, level.player2Base);

            base.Initialize();
        }
Beispiel #3
0
    // TODO future - distance we get from RayCast, has to be scaled by the coeff. which is used in Canvas
    public void SetLine(float angle, float length)
    {
        m_RectTransform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);

        m_VecSize.y = length / GUILogic.GetScale();
        m_RectTransform.sizeDelta = m_VecSize;
    }
Beispiel #4
0
 public MainWindow()
 {
     InitializeComponent();
     AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
     queryPage    = new QueryPage(this);
     downloadPage = new DownloadPage(this);
     guiLogic     = new GUILogic();
     frame.NavigationService.Navigate(queryPage);
 }
 private void Start()
 {
     mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();
     popUp      = FindObjectOfType <PopUpManager>();
     guiLogic   = FindObjectOfType <GUILogic>();
     StartCoroutine(Timer(timerMax));
     score = 0;
     guiLogic.ShowScore(score);
 }
        private void onMouseDown(object sender, MouseButtonEventArgs e)
        {
            ListViewItem item = sender as ListViewItem;

            if (item != null && item.IsSelected)
            {
                var obj = (IDictionary <string, object>)(item.Content);
                MessageBox.Show(obj["SeriesInstanceUID"].ToString());

                //now download

                QueryObject series = new SeriesResponseQuery(obj["StudyInstanceUID"].ToString(), obj["SeriesInstanceUID"].ToString());

                QueryRetrieve q = new QueryRetrieve();

                GUILogic.clearImageThumbs();


                MessageBox.Show("now download: ");

                q.move(GUILogic.readFromFile("thisMachineAE"), series, "Series", mainWindow.guiLogic);
            }
        }
Beispiel #7
0
        public static int Main(string[] args)
        {
            if (!Directory.Exists(DATADIR))
            {
                Directory.CreateDirectory(DATADIR);
            }

            if (File.Exists(CONFFILE))
            {
                try
                {
                    MadConf.LoadConf(CONFFILE);

                    Console.WriteLine("(CONFIG) Config loaded.");
                    MainWindow.configStatus = "Config loaded.";
                }
                catch (Exception e)
                {
                    Console.WriteLine("(CONFIG) Config could not be loaded: " + e.Message);
                    MadConf.SetToDefault();
                    Console.WriteLine("(CONFIG) Config could not be loaded. Using default config.");
                    MainWindow.configStatus = "Loaded default config.";
                }
            }
            else
            {
                Console.WriteLine("(CONFIG) No config file found!");
                MadConf.SetToDefault();
                Console.WriteLine("(CONFIG) Loaded default config.");
                MadConf.SaveConf(CONFFILE);
                Console.WriteLine("(CONFIG) Saved default config to '" + CONFFILE + "'.");
                Console.WriteLine("(CONFIG) Default config may not use all possible features!");
            }

            Logger.Init();
            DB        db = new DB(DBFILE);
            JobSystem js = new JobSystem(db);

            js.OnNodeCountChange += new EventHandler(ModelHost.SyncHostList);
            ModelHost.Init(ref js);
            DHCPReader dhcpReader = new DHCPReader(js);

            if (args.Length == 0)
            {
                GUI_USED = true;
                Logger.Log("Programm Start. GUI Start.", Logger.MessageType.INFORM);
                GUILogic.RunGUI(js, db, dhcpReader);
            }
            else if (args.Length == 1)
            {
                switch (args[0])
                {
                case "-cli":
                    Logger.Log("Programm Start. CLI Start.", Logger.MessageType.INFORM);
                    CLI cli = new CLI(js, dhcpReader, db);
                    cli.Start();
                    break;

                case "-cliserver":
                    Logger.Log("Programm Start. CLI Server Start.", Logger.MessageType.INFORM);
                    try
                    {
                        CLIServer cliServer = new CLIServer(js, dhcpReader, db);
                        cliServer.Start();

                        Console.WriteLine("(SERVER) Listening on port " + cliServer.serverPort + " ...");
                        Logger.Log("CLIServer started on port " + cliServer.serverPort + " ..", Logger.MessageType.INFORM);

                        Console.ReadKey(false);
                        cliServer.Stop();
                        cliServer.Dispose();

                        Console.WriteLine("(SERVER) Stopped.");
                        Logger.Log("Server stopped.", Logger.MessageType.INFORM);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("(SERVER) Could not start: " + e.Message);
                        Logger.Log("CLIServer could not start: " + e.Message, Logger.MessageType.ERROR);
                    }

                    PressAnyKeyToClose();
                    break;

                default:
                    Console.WriteLine("ERROR! Argument '" + args[0] + "' not known!");
                    Logger.Log("Programm Aborted. False Call Argument!", Logger.MessageType.EMERGENCY);
                    break;
                }
            }
            else
            {
                Console.WriteLine("ERROR! Too many arguments!");
                Logger.Log("Programm Aborted. Too many arguments!", Logger.MessageType.EMERGENCY);
                PressAnyKeyToClose();
            }

            js.Shutdown();
            db.Dispose();

            Logger.Log("Programm Exited Successfully. See Ya!", Logger.MessageType.INFORM);
            Logger.ForceWriteToLog();
            Logger.Dispose();

            if (restart)
            {
                Application.Restart();
            }

            return(0);
        }
Beispiel #8
0
 //get reference of the main GUI script
 void Awake()
 {
     gui = GetComponent <GUILogic>();
 }
Beispiel #9
0
 //get reference of the main GUI script
 void Awake()
 {
     gui = GetComponent<GUILogic>();
 }
Beispiel #10
0
    //swaps the tower model to the one defined in the corresponding upgrade option
    public void TowerChange()
    {
        //instantiate new tower model at the same position and reparent it to the Tower Manager object
        GameObject newTower = (GameObject)Instantiate(options[curLvl].swapModel, transform.position, transform.rotation);

        newTower.transform.parent = GameObject.Find("Tower Manager").transform;
        //find the TowerBase component, we have to do some adjustments to it
        TowerBase newTowerBase = newTower.GetComponentInChildren <TowerBase>();
        //get the gameobject which holds the TowerBase script,
        //and rename it to keep the old name
        GameObject subTower = newTowerBase.gameObject;

        newTower.name = newTowerBase.gameObject.name = transform.name;

        //attach and store an Upgrade script to the actual tower object,
        //copy values from the old tower
        Upgrade newUpgrade = subTower.AddComponent <Upgrade>();

        newUpgrade.curLvl    = this.curLvl;
        newUpgrade.options   = this.options;
        newTowerBase.upgrade = newUpgrade;

        //apply passive powerups to new tower
        PowerUpManager.ApplyToSingleTower(newTowerBase, newUpgrade);

        //switch TowerBase component to active state - attacks enemies
        newTowerBase.enabled = true;
        newTowerBase.rangeInd.renderer.enabled = true;

        //abort shot automatism of the new tower,
        //in order to take the last shot time of the old tower into account
        newTowerBase.CancelInvoke("CheckRange");
        float lastShot    = towerScript.lastShot;
        float invokeInSec = options[curLvl].shootDelay + lastShot - Time.time;

        if (invokeInSec < 0)
        {
            invokeInSec = 0f;
        }
        newTowerBase.StartInvoke(invokeInSec);

        //find GUI component and assign new upgrade script,
        //we do this in order to update the upgrade gui tooltip for the new tower
        GUILogic gui = GameObject.Find("GUI").GetComponent <GUILogic>();

        gui.upgrade = newUpgrade;

        //signalize enemies that the old tower was despawned,
        //here we loop through all enemies in range and remove the old tower from them.
        //they detect the new tower automatically, since enemies are colliding with it.
        for (int i = 0; i < towerScript.inRange.Count; i++)
        {
            PoolManager.Props[towerScript.inRange[i].name].RemoveTower(towerScript);
        }

        //re-rotate turret to match the old turret, if there existed one,
        //else rotate turret to match the grid rotation
        if (newTowerBase.turret)
        {
            if (towerScript.turret)
            {
                newTowerBase.turret.rotation = towerScript.turret.rotation;
            }
            else
            {
                //define ray with down direction to get the grid beneath
                Ray        ray = new Ray(transform.position + new Vector3(0, 0.5f, 0), -transform.up);
                RaycastHit hit;

                //raycast downwards of the tower against our grid mask to get the grid
                if (Physics.Raycast(ray, out hit, 20, SV.gridMask))
                {
                    Transform grid = hit.transform;
                    newTowerBase.turret.rotation = grid.rotation;
                }
            }
            //don't let the tower/turret rotation affect shot position rotation
            newTowerBase.shotPos.localRotation = Quaternion.identity;

            //enable turret rotation mechanism
            newTowerBase.turret.GetComponent <TowerRotation>().enabled = true;
        }

        //destroy (this) old tower
        Destroy(transform.parent.gameObject);
    }
Beispiel #11
0
 // TODO future - distance we get from RayCast, has to be scaled by the coeff. which is used in Canvas
 void SetLineLength(float length)
 {
     m_VecSize.y = length / GUILogic.GetScale();
     m_RectTransform.sizeDelta = m_VecSize;
 }