예제 #1
0
        public NavigationObject(
            GUIListControl control, string title, string itemtype, string nbobjects, string moviecontext, int pos, MyFilms.Layout curview,
            Configuration curconf, GUISortButtonControl srtButton, GUIButtonControl viewButton, GUIButtonControl layoutButton,
            CoverState coverstate, DateTime lastDBupdate)
        {
            Items = new List<GUIListItem>();
              GetItems(control, title, itemtype, pos, curview);
              ViewStatus = new ViewState();
              GetViewStatus(curconf);

              DbDfltSelect = curconf.DbSelection[0];
              DbSelect = curconf.DbSelection[1];
              DbField = curconf.DbSelection[2];
              DbSort = curconf.DbSelection[3];
              bool showall;
              DbShowAll = Boolean.TryParse(curconf.DbSelection[4], out showall) && showall;
              bool extrasort;
              DbExtraSort = Boolean.TryParse(curconf.DbSelection[4], out extrasort) && extrasort;

              NbObjects = nbobjects;
              MovieContext = moviecontext;

              CurrentView = curview;

              SortButtonEnabled = srtButton.IsEnabled;
              SortButtonAsc = srtButton.IsAscending;
              SortButtonLabel = srtButton.Label;
              ViewAsButtonLabel = viewButton.Label;
              LayoutButtonLabel = layoutButton.Label;
              CoverStatus = coverstate;
              LastDbUpdate = lastDBupdate;
        }
예제 #2
0
 private void PlayAudioOnTransit()
 {
     if (state == CoverState.TowardsOpen && Book.coverMapping.value > 0.25f)
     {
         state = CoverState.FromOpen;
         float volume = Player.instance.leftHand.GetTrackedObjectVelocity().magnitude * 0.5f - 0.1f;
         PlayAudio(volume, slowOpenClip);
         // Debug.Log(state);
     }
     // else if (state == CoverState.TowardsShut && Book.coverMapping.value < 0.2f)
     // {
     //     state = CoverState.FromShut;
     //     Debug.Log(state);
     // }
     else if ((state == CoverState.FromOpen || state == CoverState.TowardsOpen) && Book.coverMapping.value < 0.01f)
     {
         state = CoverState.FromShut;
         float volume = isDriving ? Player.instance.leftHand.GetTrackedObjectVelocity().magnitude * 0.5f - 0.1f : 0.1f;
         if (attachedToPrimary)
         {
             PlayAudio(volume, shutClip);
         }
         // Debug.Log(state);
     }
     else if (state == CoverState.FromShut && Book.coverMapping.value > 0.05f)
     {
         state = CoverState.TowardsOpen;
         // Debug.Log(state);
     }
     audioLockTimer = Mathf.Max(audioLockTimer - Time.deltaTime, 0f);
 }
예제 #3
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "bulletPlayer")
     {
         currentState = CoverState.Dead;
     }
 }
		private ViewSettingsManager()
		{
			CoverState = new CoverState();
			LeadoffStatementState = new LeadoffStatementState();
			ClientGoalsState = new ClientGoalsState();
			TargetCustomersState = new TargetCustomersState();
			SimpleSummaryState = new SimpleSummaryState();
		}
 // Starts the FadeIn coroutine if we're not already in the middle of a coroutine. Otherwise nothing happens.
 public void StartFadeIn()
 {
     if (_gameState == CoverState.None)
     {
         _gameState = CoverState.FadingIn;
         StartCoroutine(FadeIn());
     }
 }
예제 #6
0
 private ViewSettingsManager()
 {
     CoverState            = new CoverState();
     LeadoffStatementState = new LeadoffStatementState();
     ClientGoalsState      = new ClientGoalsState();
     TargetCustomersState  = new TargetCustomersState();
     SimpleSummaryState    = new SimpleSummaryState();
 }
예제 #7
0
 public async Task TestCoverState(CoverState coverState, string deviceResponse)
 {
     Assert.That(await _sut.Connect(new CancellationToken()), Is.True);
     _mockSdk.Setup(m => m.SendCommand <StateResponse>(It.IsAny <StateCommand>()))
     .Returns(Task.FromResult(new StateResponse {
         DeviceResponse = deviceResponse
     }));
     Assert.That(_sut.CoverState, Is.EqualTo(coverState));
 }
 public void SetFact(
     Facts fact,
     CoverState value,
     bool invokeChangedEvent = true,
     bool setAsDirty         = true,
     bool checkValueDiff     = true)
 {
     this.SetFact(fact, (byte)value, invokeChangedEvent, setAsDirty, checkValueDiff);
 }
예제 #9
0
        public void TestLocalizedCoverState(CoverState expected)
        {
            var sut = new FlatDeviceInfo {
                CoverState = expected
            };

            Assert.That(sut.CoverState, Is.EqualTo(expected));
            Assert.That(sut.LocalizedCoverState, Is.EqualTo(Loc.Instance[$"LblFlatDevice{expected}"]));
        }
 // Coroutine to remove the cover from the the player's screen
 private IEnumerator FadeOut()
 {
     _time = 0f;
     while (_time < FadeOutTime)
     {
         Fade(1, 0, FadeOutTime);  // 1 is opaque, 0 is transparent
         yield return(null);       // wait until the next frame
     }
     _gameState = CoverState.None; // now that we're done, go back to the none state
 }
예제 #11
0
        public void TestValidStateResponse(string response, bool motorRunning, CoverState covertState, bool lightOn)
        {
            var sut = new StateResponse {
                DeviceResponse = response
            };

            sut.Ttl.Should().Be(0);
            sut.MotorRunning.Should().Be(motorRunning);
            sut.CoverState.Should().Be(covertState);
            sut.LightOn.Should().Be(lightOn);
        }
예제 #12
0
 void Start()
 {
     //childrenImages = transform.GetComponentsInChildren<Image>(true);
     childrenImages = new Image[4];
     for (int e = 0; e < childrenImages.Length; e++)
     {
         childrenImages[e] = transform.GetChild(e).GetComponent <Image>();
     }
     MyCover        = childrenImages[3].GetComponent <CanvasGroup>();
     MyCoverState   = CoverState.Other;
     prevCoverState = CoverState.Other;
     fCover         = 0;
 }
예제 #13
0
    private void Awake()
    {
        alertState    = new AlertState(this);
        coverState    = new CoverState(this);
        checkState    = new CheckState(this);
        engageState   = new EngageState(this);
        examineState  = new ExamineState(this);
        flankState    = new FlankState(this);
        patrolState   = new PatrolState(this);
        suppressState = new SuppressState(this);

        navMeshAgent = GetComponent <NavMeshAgent>();

        enemyHealth = GetComponent <EnemyHealth>();
    }
    void UpdateCurrentCoverState()
    {
        CoverState cs = CoverState.Full;

        List <Pawn> enemies = GetComponent <Pawn>().sightList.FindAll(x => x.owner != GetComponent <Pawn>().owner);

        GetComponentInChildren <Animator>().SetBool("Ducking", false);

        foreach (Pawn e in enemies)
        {
            if (Pawn.GetCoverAtNode(GetComponent <Pawn>().currentNode, e) == CoverState.Half)
            {
                GetComponentInChildren <Animator>().SetBool("Ducking", true);
            }
        }
    }
예제 #15
0
 // Update is called once per frame
 public void ChangeCoverT(int Tw)
 {
     if (Tw == 0)
     {
         MyCoverState = CoverState.Other;
     }
     else if (Tw == 1)
     {
         MyCoverState = CoverState.XI;
     }
     else if (Tw == 2)
     {
         MyCoverState = CoverState.XIII;
     }
     else if (Tw == 3)
     {
         MyCoverState = CoverState.XIX;
     }
 }
        internal void UpdateCover(CoverState cs)
        {
            Debug("Cover selected + " + cs.ToString());

            if (_coverState != cs)
            {
                _coverState = cs;

                switch (_coverState)
                {
                case CoverState.Blank:
                    Cover         = null;
                    CoverTemplate = null;
                    break;

                case CoverState.Timeout:
                    Cover         = TimeoutContent;
                    CoverTemplate = TimeoutContentTemplate;
                    break;

                case CoverState.Failure:
                    Cover         = FailureContent;
                    CoverTemplate = FailureContentTemplate;
                    break;

                case CoverState.FailureRetry:
                    Cover         = RetryContent;
                    CoverTemplate = RetryContentTemplate;
                    break;

                case CoverState.Loading:
                    Cover         = LoadingContent;
                    CoverTemplate = LoadingContentTemplate;
                    break;

                default:
                    throw new InvalidOperationException();
                }
            }
        }
예제 #17
0
    void Update()
    {
        if (MyCoverState != prevCoverState)
        {
            coverRun       = CoverRun.Cover;
            prevCoverState = MyCoverState;
        }
        if (coverRun == CoverRun.Cover)
        {
            fCover       += Time.deltaTime * 2;
            MyCover.alpha = fCover;
            if (fCover > 1)
            {
                fCover = 1;
                ExchangeGraphic();
                coverRun      = CoverRun.Uncover;
                MyCover.alpha = fCover;
            }
            childrenImages[3].gameObject.SetActive(true);
        }
        else if (coverRun == CoverRun.Uncover)
        {
            fCover -= Time.deltaTime * 2;
            if (fCover < 0)
            {
                fCover = 0;
                // hidecover
                coverRun = CoverRun.Done;
                childrenImages[3].gameObject.SetActive(false);
            }
            MyCover.alpha = fCover;
        }
        //


        // uncover
    }
예제 #18
0
        private bool ParseState(string response)
        {
            if (!TryParseBoolFromZeroOne(response[4], "fifth letter of response", out _motorRunning))
            {
                return(false);
            }
            if (!TryParseBoolFromZeroOne(response[5], "sixth letter of response", out _lightOn))
            {
                return(false);
            }

            switch (response[6])
            {
            case '0':
                CoverState = CoverState.NeitherOpenNorClosed;
                break;

            case '1':
                CoverState = CoverState.Closed;
                break;

            case '2':
                CoverState = CoverState.Open;
                break;

            case '3':
                CoverState = CoverState.Unknown;
                break;

            default:
                Logger.Debug($"Seventh letter of response should have been 0, 1, 2 or 3. Actual value:{response}");
                return(false);
            }

            return(true);
        }
 public void PushFactChangeDuringPlanning(Facts fact, CoverState value, bool temporary)
 {
     this.PushFactChangeDuringPlanning((byte)fact, (byte)value, temporary);
 }
예제 #20
0
        //private SearchParameters searchParameters;

        private void btnGenerateMap_Click(object sender, EventArgs e)
        {
            txtMap.Text = "";
            int height = 5;
            int width  = 7;

            // Start with a clear map (don't add any obstacles)
            InitializeMap(width, height);
            List <Point> path = new List <Point>();// pathFinder.FindPath();

            // Now add an obstacle
            Point startingLocation = new Point(0, 0);

            map[3, 2] = "X";

            CoverState cover = Cover.CalculateCover(startingLocation, map, null);

            txtMap.Text += ShowRoute("The algorithm should find a possible tiles, ignoring the obstacle:", startingLocation, path);
            txtMap.Text += Environment.NewLine;
            if (cover.IsInCover == true)
            {
                txtMap.Text += "The player is in cover. ";
                if (cover.InNorthCover == true)
                {
                    txtMap.Text += "North cover detected. ";
                }
                else if (cover.InEastCover == true)
                {
                    txtMap.Text += "East cover detected. ";
                }
                else if (cover.InSouthCover == true)
                {
                    txtMap.Text += "South cover detected. ";
                }
                else if (cover.InWestCover == true)
                {
                    txtMap.Text += "West cover detected. ";
                }
            }
            else
            {
                txtMap.Text += "The player is NOT in cover. ";
            }

            //// Create a barrier between the start and end points
            //InitializeMap(7, 5, Point.Empty, Point.Empty);
            //AddWallWithoutGap();
            //pathFinder = new PathFinding(searchParameters);
            //path = pathFinder.FindPath();
            //txtMap.Text += ShowRoute("The algorithm should not be able to find a route around the barrier:", path);
            //txtMap.Text += Environment.NewLine;


            //// Create a maze with custom start and end points
            //InitializeMap(7, 5, new Point(0, 4), new Point(6, 4));
            //AddWallWithMaze();
            //pathFinder = new PathFinding(searchParameters);
            //path = pathFinder.FindPath();
            //txtMap.Text += ShowRoute("The algorithm should be able to find a long route around the barrier:", path);
            //txtMap.Text += Environment.NewLine;


            //// Create a maze with custom start and end points
            //InitializeMap(7, 5, new Point(0, 4), new Point(4, 2));
            //AddWallWithSpinningMaze();
            //pathFinder = new PathFinding(searchParameters);
            //path = pathFinder.FindPath();
            //txtMap.Text += ShowRoute("The algorithm should be able to find a long route around the barrier:", path);
            //txtMap.Text += Environment.NewLine;


            // Create a larger maze with custom start and end points
            //InitializeMap(70, 40, new Point(0, 0), new Point(69, 39), false);
            //AddRandomItems(70, 40, 40);
            //pathFinder = new PathFinding(searchParameters);
            //path = pathFinder.FindPath();
            //txtMap.Text += ShowRoute("The algorithm should be able to find a long route around the random blocks:", path);
            //txtMap.Text += Environment.NewLine;

            //Console.WriteLine("Press any key to exit...");
            //Console.ReadKey();
        }
    private CoverState _gameState;          // The current state we're in

    void Start()
    {
        _screenCoverRenders = GetComponentsInChildren <Renderer>(); // get all the renderer of our child game objects
        SetCoverAlpha(0);
        _gameState = CoverState.None;
    }
        internal void UpdateCover(CoverState cs)
        {
            Debug("Cover selected + " + cs.ToString());

            if (_coverState != cs)
            {
                _coverState = cs;

                switch (_coverState)
                {
                    case CoverState.Blank:
                        Cover = null;
                        CoverTemplate = null;
                        break;

                    case CoverState.Timeout:
                        Cover = TimeoutContent;
                        CoverTemplate = TimeoutContentTemplate;
                        break;

                    case CoverState.Failure:
                        Cover = FailureContent;
                        CoverTemplate = FailureContentTemplate;
                        break;

                    case CoverState.FailureRetry:
                        Cover = RetryContent;
                        CoverTemplate = RetryContentTemplate;
                        break;

                    case CoverState.Loading:
                        Cover = LoadingContent;
                        CoverTemplate = LoadingContentTemplate;
                        break;

                    default:
                        throw new InvalidOperationException();
                }
            }
        }
예제 #23
0
    // Update is called once per frame
    void Update()
    {
        ColorChange();
        a = target - transform.position;
        Vector3 fwd       = transform.TransformDirection(Vector3.forward);
        Vector3 leftCast  = transform.TransformDirection(Vector3.left);
        Vector3 rightCast = transform.TransformDirection(Vector3.right);

        switch (currentState)
        {
        case CoverState.MoveRandom:
            if (transform.position == currentNode.transform.position)
            {
                RandomMove();
            }
            if (playerTarget.GetComponent <PlayerScript>().fired == true)
            {
                currentState = CoverState.MoveToCover;
                NewCover();
                Debug.Log(currentState);
            }
            if ((Physics.Raycast(leftFoward.transform.position, fwd, out hit, detectDistance) || Physics.Raycast(rightFoward.transform.position, fwd, out hit, detectDistance)) && hit.transform.CompareTag("Player"))
            {
                currentState = CoverState.MoveToCover;
                NewCover();
                Debug.Log(currentState);
            }
            transform.position    = Vector3.MoveTowards(transform.position, currentNode.transform.position, speed * Time.deltaTime);
            transform.rotation    = Quaternion.LookRotation(Vector3.RotateTowards(transform.forward, a, speed * Time.deltaTime, 0.0f));
            transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
            break;

        case CoverState.MoveToCover:
            if (partnerAI.transform.position == coverSpot.transform.position)
            {
                NewCover();
            }
            else if (transform.position == coverSpot.transform.position)
            {
                currentState = CoverState.WaitCover;
                Debug.Log(currentState);
                waitTime = 0;
            }
            else if (transform.position == currentNode.transform.position)
            {
                TargetMove();
            }
            transform.position    = Vector3.MoveTowards(transform.position, currentNode.transform.position, speed * Time.deltaTime);
            transform.rotation    = Quaternion.LookRotation(Vector3.RotateTowards(transform.forward, a, speed * Time.deltaTime, 0.0f));
            transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
            break;

        case CoverState.WaitCover:
            waitTime += Time.deltaTime;
            Vector3 hideCover = new Vector3(coverSpot.transform.position.x, 0.0f, coverSpot.transform.position.z);
            FaceCover();
            if (Physics.Raycast(leftFoward.transform.position, leftCast, out hit, detectDistance) && hit.transform.tag == "Player")
            {
                currentState = CoverState.MoveToCover;
                NewCover();
                Debug.Log(currentState);
            }
            else if (Physics.Raycast(rightFoward.transform.position, rightCast, out hit, detectDistance) && hit.transform.tag == "Player")
            {
                currentState = CoverState.MoveToCover;
                NewCover();
                Debug.Log(currentState);
            }
            else if (waitTime >= 5.0f)
            {
                currentState  = CoverState.CheckInCover;
                lookTime      = 0.0f;
                playerInSight = false;
                Debug.Log(currentState);
            }
            transform.position = Vector3.MoveTowards(transform.position, hideCover, speed * Time.deltaTime);
            break;

        case CoverState.CheckInCover:
            Vector3 lookCover = new Vector3(coverSpot.transform.position.x, 0.5f, coverSpot.transform.position.z);
            lookTime += Time.deltaTime;
            if (Physics.Raycast(leftFoward.transform.position, leftCast, out hit, detectDistance) && hit.transform.tag == "Player")
            {
                currentState = CoverState.MoveToCover;
                NewCover();
                Debug.Log(currentState);
            }
            else if (Physics.Raycast(rightFoward.transform.position, rightCast, out hit, detectDistance) && hit.transform.tag == "Player")
            {
                currentState = CoverState.MoveToCover;
                NewCover();
                Debug.Log(currentState);
            }
            else if (lookTime >= 10.0f)
            {
                if (playerInSight == true)
                {
                    currentState = CoverState.WaitCover;
                    waitTime     = 0.0f;
                    Debug.Log(currentState);
                }
                else
                {
                    currentState = CoverState.MoveRandom;
                }
            }

            if ((Physics.Raycast(leftFoward.transform.position, fwd, out hit, detectDistance) || Physics.Raycast(rightFoward.transform.position, fwd, out hit, detectDistance)) && hit.transform.tag == "Player")
            {
                Shoot();
                playerInSight = true;
            }
            transform.position = Vector3.MoveTowards(transform.position, lookCover, speed * Time.deltaTime);
            break;

        case CoverState.Dead:
            dead = true;
            break;

        default:
            break;
        }
        ;

        Debug.DrawRay(transform.position, fwd, Color.black);
    }
예제 #24
0
    public static void Attack(Pawn owner, Targetable target)
    {
        if (target.GetComponent <DestroyableProp>() != null)
        {
            Weapon weapon = owner.weapon;

            int effectiveRange = weapon.range;
            if (owner.transform.position.y - target.transform.position.y > 0)
            {
                effectiveRange += (int)((owner.transform.position.y - target.transform.position.y) / 2f);
            }
            double hitChance = 1 - (1 - 0.5) * (Vector3.Distance(owner.transform.position, target.transform.position) - 1) / (effectiveRange - 1);
            if (owner.hitMulti != 0)
            {
                hitChance *= owner.hitMulti;
            }
            Debug.Log(System.Math.Round(hitChance * 100) + "% chance to hit");
            if (RNG.NextDouble() < hitChance)
            {
                Debug.Log(owner + " hit " + target);
                target.GetComponent <Health>().Damage(owner, 1);
            }
            else
            {
                Debug.Log(owner + " missed " + target);
            }
            for (int i = owner.EffectList.Count - 1; i >= 0; i--)
            {
                owner.EffectList[i].OnRemove();
            }
        }
        else if (target.GetComponent <Pawn>() != null)
        {
            Weapon weapon = owner.weapon;

            int effectiveRange = weapon.range;
            if (owner.transform.position.y - target.transform.position.y > 0)
            {
                effectiveRange += (int)((owner.transform.position.y - target.transform.position.y) / 2f);
            }
            double     hitChance  = 1 - (1 - 0.5) * (Vector3.Distance(owner.transform.position, target.transform.position) - 1) / (effectiveRange - 1);
            CoverState coverState = target.GetComponent <Pawn>().GetCoverState(owner);
            switch (coverState)
            {
            case CoverState.Half:
                owner.EffectList.Add(new HalfCoverDebuff(owner));
                break;

            case CoverState.Full:
                owner.EffectList.Add(new FullCoverDebuff(owner));
                break;
            }
            if (owner.hitMulti != 0)
            {
                hitChance *= owner.hitMulti;
            }
            Debug.Log(System.Math.Round(hitChance * 100) + "% chance to hit");
            if (RNG.NextDouble() < hitChance)
            {
                int    damage   = weapon.damage;
                double accuracy = owner.Accuracy;
                if (owner.accuracyMulti != 0)
                {
                    accuracy *= owner.accuracyMulti;
                }
                accuracy = (accuracy + owner.accuracyMod) / 100d;
                if (1 - accuracy <= 0)
                {
                    accuracy = 1d;
                }
                double tmpDamageMod = (1 - accuracy) * RNG.NextDouble() + accuracy;
                if (tmpDamageMod > 1d)
                {
                    tmpDamageMod = 1d;
                }
                if (owner.damageMulti != 0)
                {
                    tmpDamageMod *= owner.damageMulti;
                }
                if (RNG.NextDouble() < weapon.criticalChance + owner.critChanceMod)
                {
                    damage = (int)System.Math.Round((double)weapon.damage * 1.5d * tmpDamageMod);
                    if (damage < 1)
                    {
                        damage = 1;
                    }
                    Debug.Log(owner + " critically hit " + target + " and dealt " + damage + " damage.");
                    target.GetComponent <Health>().Damage(owner, damage);
                }
                else
                {
                    damage = (int)System.Math.Round((double)weapon.damage * tmpDamageMod);
                    if (damage < 1)
                    {
                        damage = 1;
                    }
                    Debug.Log(owner + " hit " + target + " and dealt " + damage + " damage.");
                    target.GetComponent <Health>().Damage(owner, damage);
                }
                if (weapon.weaponEffects != null)
                {
                    for (int i = weapon.weaponEffects.Count - 1; i >= 0; i--)
                    {
                        Factory.GetWeaponEffect(weapon.weaponEffects[i]).Execute(owner, weapon, target.GetComponent <Pawn>());
                    }
                }
                for (int i = target.GetComponent <Pawn>().EffectList.Count - 1; i >= 0; i--)
                {
                    target.GetComponent <Pawn>().EffectList[i].OnHit(owner, damage);
                }
            }
            else
            {
                Debug.Log(owner + " missed " + target);
            }
            for (int i = owner.EffectList.Count - 1; i >= 0; i--)
            {
                owner.EffectList[i].OnRemove();
            }
        }
    }
예제 #25
0
 public void SetCoverState(CoverState _c)
 {
     this_enemy_cover_state = _c; OnChange();
 }