Esempio n. 1
0
    void Start()
    {
        // TODO figure out a better way to do this
        LevelManager.isPaused = false;
        alive = true;

        ship = gameObject.GetComponentInParent <ShipController>();
        targetIndicatorEnabled = false;
        velocityVector         = gameObject.transform.Find("VelocityVector").GetComponent <LineRenderer>();
        fc       = gameObject.GetComponent <FiringController>();
        ship.IFF = "green";

        menuCanvas = GameObject.Find("MenuCanvas");
        Debug.Log("Canvas found with name: " + menuCanvas.name);
        menuCanvas.SetActive(false);
        levelManager = GameObject.Find("LevelManager").GetComponent <LevelManager>();

        weaponText    = GameObject.Find("UIWeaponText").GetComponent <WeaponTextScript>();
        radarText     = GameObject.Find("UIRadarText").GetComponent <UIRadarText>();
        fuelSlider    = GameObject.Find("FuelSlider").GetComponent <Slider>();
        healthSlider  = GameObject.Find("HealthSlider").GetComponent <Slider>();
        initialHealth = ship.health;

        selectedWeapon = Weapon.plasma;
        weaponText.SetUIWeapontext("plasma");
        SetCursorGame();

        float distance = transform.position.z - Camera.main.transform.position.z;

        camera.orthographicSize = initialZoom;

        InvokeRepeating("UpdateUI", 0.00001f, 0.5f);
    }
Esempio n. 2
0
 // Use this for initialization
 void Start()
 {
     movementActuator = this.GetComponentInParent <CharacterMovementActuator>() as CharacterMovementActuator;
     contactSensor    = this.GetComponentInParent <CharacterContactSensor>() as CharacterContactSensor;
     aimingController = this.GetComponent <AimingController>() as AimingController;
     firingController = this.GetComponent <FiringController>() as FiringController;
     itemManager      = this.GetComponent <ItemManager> () as ItemManager;
 }
Esempio n. 3
0
    void Start()
    {
        camSetting   = (SettingsStatic.CamSettings)SettingsManager.GetCameraSetting();
        camPlayerSet = false;

        ScoreKeeper.shots       = 0;
        ScoreKeeper.hits        = 0;
        ScoreKeeper.playerKills = 0;

        // TODO figure out a better way to do this
        LevelManager.isPaused = false;
        alive = true;

        ship       = gameObject.GetComponentInParent <ShipController>();
        ship.owner = gameObject.GetComponent <PlayerController>();

        targetIndicatorEnabled = false;
        velocityVector         = gameObject.transform.Find("VelocityVector").GetComponent <LineRenderer>();
        leadLine.enabled       = false;
        fc = gameObject.GetComponent <FiringController>();
        //ship.IFF = "green";

        menuCanvas  = GameObject.Find("MenuCanvas");
        hintsCanvas = GameObject.Find("HintsCanvas");
        // Debug.Log("Canvas found with name: " + menuCanvas.name);
        if (menuCanvas != null)
        {
            menuCanvas.SetActive(false);
        }
        if (hintsCanvas != null)
        {
            hintsCanvas.SetActive(false);
        }

        levelManager = GameObject.Find("LevelManager").GetComponent <LevelManager>();

        weaponText    = GameObject.Find("UIWeaponText").GetComponent <WeaponTextScript>();
        radarText     = GameObject.Find("UIRadarText").GetComponent <UIRadarText>();
        fuelSlider    = GameObject.Find("FuelSlider").GetComponent <Slider>();
        healthSlider  = GameObject.Find("HealthSlider").GetComponent <Slider>();
        contactsText  = GameObject.Find("UIContactsText").GetComponent <UIContactsText>();
        initialHealth = ship.health;

        selectedWeapon = Weapon.plasma;
        weaponText.SetUIWeapontext("Plasma");
        radarText.SetUIRadarText("off");
        SetCursorGame();

        // float distance = transform.position.z - Camera.main.transform.position.z;
        camera.fieldOfView = initialZoom;

        InvokeRepeating("UpdateUI", 0.00001f, 0.5f);
        Invoke("LateStart", 0.5f);
        lockIndicator.SetActive(false);

        ResizeMinimap();
    }
        public void Fire()
        {
            FiringController f = FiringController.GetOrCreateFiringController();

            f.FiringControlReady += f_FiringControlReady;
            f.TryInitialize();
            System.Threading.Thread.Sleep(1000);
            Assert.AreEqual(false, isFiring);
        }
Esempio n. 5
0
    public void RegisterCharacterComponentsWithWeapon()
    {
        aimingController   = this.transform.parent.parent.Find("ActionControllers").GetComponent <AimingController>();
        firingController   = this.transform.parent.parent.Find("ActionControllers").GetComponent <FiringController>();
        movementController = this.transform.parent.parent.Find("ActionControllers").GetComponent <MovementController>();

        character     = this.transform.parent.parent.GetComponent <Character>() as Character;
        contactSensor = this.transform.parent.parent.GetComponent <CharacterContactSensor>() as CharacterContactSensor;
    }
    void RegisterControllers()
    {
        GameObject actionControllers = this.transform.parent.FindChild("ActionControllers").gameObject;

        movementController = actionControllers.GetComponent <MovementController>();
        aimingController   = actionControllers.GetComponent <AimingController>();
        firingController   = actionControllers.GetComponent <FiringController>();
        itemManager        = actionControllers.GetComponent <ItemManager>();
        corpus             = GetComponentInParent <CharacterCorpus> () as CharacterCorpus;
    }
 public CharacterComponentData(Character C)
 {
     character          = C;
     aimingController   = C.GetComponentInChildren <AimingController> () as AimingController;
     firingController   = C.GetComponentInChildren <FiringController> () as FiringController;
     movementController = C.GetComponentInChildren <MovementController> () as MovementController;
     movementActuator   = C.GetComponent <CharacterMovementActuator> () as CharacterMovementActuator;
     itemManager        = C.GetComponentInChildren <ItemManager>() as ItemManager;
     corpus             = C.GetComponent <CharacterCorpus> () as CharacterCorpus;
     characterTransform = movementActuator.transform;
 }
Esempio n. 8
0
    void Start()
    {
        horizontalAiming = 0;
        verticalAiming   = 0;
        horizontalInput  = 0;
        verticalInput    = 0;
        isAiming         = false;
        isWallAdjacent   = false;
        wallSide         = MovementDirection.NEUTRAL;

        firingController = GetComponent <FiringController> () as FiringController;

        characterContact = this.transform.parent.GetComponent <CharacterContactSensor>() as CharacterContactSensor;
        movementActuator = GetComponentInParent <CharacterMovementActuator> () as CharacterMovementActuator;
    }
Esempio n. 9
0
    // Use this for initialization
    void Start()
    {
        firingController = this.transform.parent.GetComponentInChildren <FiringController> () as FiringController;
        aimingController = this.transform.parent.GetComponentInChildren <AimingController>() as AimingController;
        movementActuator = GetComponentInParent <CharacterMovementActuator> () as CharacterMovementActuator;
        character        = GetComponentInParent <Character> () as Character;
        hand             = this.transform.parent.GetComponentInChildren <Hand> () as Hand;

        componentData = new CharacterComponentData(character);

        itemWheel = GetComponentInChildren <ItemWheel> () as ItemWheel;

        instantiatedDefault = Instantiate(defaultItemPrefab, this.transform.position, Quaternion.identity) as Item;
        instantiatedDefault.SetItemStateHeld();
        EquipItem(instantiatedDefault);
        inventory = new List <Item>();
        AddItemToInventory(instantiatedDefault);
    }
Esempio n. 10
0
        public MainWindow()
        {
            // one sensor is currently supported
            this.kinectSensor = KinectSensor.GetDefault();

            // get the coordinate mapper
            this.coordinateMapper = this.kinectSensor.CoordinateMapper;

            // open the reader for the body frames
            this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();

            this.colorFrameReader = this.kinectSensor.ColorFrameSource.OpenReader();

            this.audioReader = this.kinectSensor.AudioSource.OpenReader();

            // get the depth (display) extents
            FrameDescription jointFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;

            FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra);

            FrameDescription infraredFrameDescription = this.kinectSensor.InfraredFrameSource.FrameDescription;

            colorRenderer = new ColorFrameRenderer(colorFrameDescription.Width, colorFrameDescription.Height, jointFrameDescription.Width, jointFrameDescription.Height,
                                                   infraredFrameDescription.Width, infraredFrameDescription.Height);
            var drawingGroup = new DrawingGroup();
            var drawingImage = new DrawingImage(drawingGroup);

            hudRenderer = new HudRenderer(drawingGroup, drawingImage, colorFrameDescription.Width, colorFrameDescription.Height);

            AudioSource audioSource = this.kinectSensor.AudioSource;

            // Allocate 1024 bytes to hold a single audio sub frame. Duration sub frame
            // is 16 msec, the sample rate is 16khz, which means 256 samples per sub frame.
            // With 4 bytes per sample, that gives us 1024 bytes.
            this.audioBuffer = new byte[audioSource.SubFrameLengthInBytes];

            this.colorFrameReader.FrameArrived += this.Reader_ColorFrameArrived;

            this.audioReader.FrameArrived += audioReader_FrameArrived;

            //on startup hide the audio meter
            AudioMeterVisibility = Visibility.Hidden;

            this.infraredFrameReader = this.kinectSensor.InfraredFrameSource.OpenReader();

            //Infrared
            // open the reader for the depth frames
            this.infraredFrameReader = this.kinectSensor.InfraredFrameSource.OpenReader();

            // wire handler for frame arrival
            this.infraredFrameReader.FrameArrived += this.colorRenderer.Reader_InfraredFrameArrived;

            // set IsAvailableChanged event notifier
            this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;

            // open the sensor
            this.kinectSensor.Open();

            // set the status text TODO: change namespace name in resources
            this.StatusText = this.kinectSensor.IsAvailable ? Microsoft.Samples.Kinect.BodyBasics.Properties.Resources.RunningStatusText
                                                            : Microsoft.Samples.Kinect.BodyBasics.Properties.Resources.NoSensorStatusText;

            // use the window object as the view model in this simple example
            this.DataContext = this;

            // initialize the components (controls) of the window
            this.InitializeComponent();

            //register the code which will tell the system what to do when keys are pressed
            SetupKeyHandlers();


            //initialize
            panTilt       = PanTiltController.GetOrCreatePanTiltController();
            firingControl = FiringController.GetOrCreateFiringController();

            var panTiltErr = panTilt.TryInitialize();
            var firingErr  = firingControl.TryInitialize();

            if (panTiltErr != null)
            {
                //crash the app. we can't do anything if it doesn't intialize
                throw panTiltErr;
            }

            if (firingErr != null)
            {
                //crash the app. we can't do anything if it doesn't intialize
                throw firingErr;
            }

            string safetyText;

            if (this.firingControl.VirtualSafetyOn)
            {
                safetyText = Microsoft.Samples.Kinect.BodyBasics.Properties.Resources.SafetyDisengagedText;
            }
            else
            {
                safetyText = Microsoft.Samples.Kinect.BodyBasics.Properties.Resources.SafetyEngagedText;
            }
            panTilt.TryInitialize();

            //draw the headsup display initially
            this.hudRenderer.RenderHud(new HudRenderingParameters()
            {
                CannonX = this.CannonX,
                CannonY = this.CannonY,
                //CannonTheta = this.CannonTheta,
                StatusText       = this.statusText,
                SystemReady      = (this.kinectSensor.IsAvailable && this.kinectSensor.IsOpen && this.panTilt.IsReady),
                FrameRate        = this.FrameRate,
                TrackingMode     = this.trackingMode,
                FiringSafety     = this.firingControl.VirtualSafetyOn,
                FiringSafetyText = safetyText
            });

            //set voice synth to Hazel
            this.voiceSynth.SelectVoice("Microsoft Hazel Desktop");

            this.voiceSynth.SpeakAsync("Kinect Cannon Fully Initialized");


            //debug start frame rate counter
            FPSTimerStart();

            // Try to use the controller
        }
Esempio n. 11
0
    void Start()
    {
        Singleton = this;

        fire = true;
    }
Esempio n. 12
0
        public void ParseGameContentXML(XDocument x)
        {
            foreach (XElement xel in x.Root.Elements())
            {
                BaseModel model;
                if (xel.Attribute("type").Value == "Generic")
                {
                    model = modelFactory.BuildGenericEnemyModel(
                        xel.Attribute("type").Value,
                        xel.Attribute("texture").Value,
                        Double.Parse(xel.Attribute("startlife").Value),
                        Double.Parse(xel.Attribute("endlife").Value),
                        new Point(Int32.Parse(xel.Attribute("x").Value), Int32.Parse(xel.Attribute("y").Value)),
                        Int32.Parse(xel.Attribute("health").Value),
                        Double.Parse(xel.Attribute("speed").Value));
                }
                else
                {
                    model = modelFactory.Build(
                        xel.Attribute("type").Value,
                        xel.Attribute("texture") != null ? xel.Element("texture").Value : xel.Attribute("type").Value,
                        Double.Parse(xel.Attribute("startlife").Value),
                        Double.Parse(xel.Attribute("endlife").Value),
                        Int32.Parse(xel.Attribute("x").Value),
                        Int32.Parse(xel.Attribute("y").Value));
                    model.SetRate(xel.Attribute("speed") != null ? Double.Parse(xel.Attribute("speed").Value) : model.Rate);
                }

                foreach (XElement xxel in xel.Elements())
                {
                    if (xxel.Name.LocalName == "move")
                    {
                        string name = xxel.Attribute("type").Value;
                        AbstractMovePattern movePattern = MoveFactory.Build(name);

                        // we have options
                        if (xxel.Element("options") != null)
                        {
                            var options = xxel.Element("options");
                            movePattern.WithOptions(options);
                        }
                        double start = Double.Parse(xxel.Attribute("start").Value);
                        double stop  = Double.Parse(xxel.Attribute("stop").Value);
                        MoveController.From(model).Between(start, stop).Pattern(movePattern);
                    }
                    else if (xxel.Name.LocalName == "firingpattern")
                    {
                        // set the required parameters for the initial firing pattern
                        string name = xxel.Attribute("type").Value;
                        AbstractFiringPattern firingPattern = FiringFactory.Build(name);
                        double start = Double.Parse(xxel.Attribute("start").Value);
                        double stop  = Double.Parse(xxel.Attribute("stop").Value);

                        // parse any extra options
                        if (xxel.Element("options") != null)
                        {
                            var options = xxel.Element("options");
                            firingPattern.WithOptions(options);
                            firingPattern.WithCoreOptions(options);
                        }

                        // get the base firing pattern
                        firingPattern = FiringController.From(model).Between(start, stop).Pattern(firingPattern);

                        // handle firing patterns for all bullets based off the base firing pattern
                        NestedFiringPatterns(firingPattern, xxel);
                    }
                }
            }
        }
Esempio n. 13
0
 void f_FiringControlReady(FiringController sender, FiringControllerReadyArgs args)
 {
     sender.VirtualSafetyOn = false;
     sender.Fire(500);
     isFiring = sender.IsFiring();
 }