Example #1
0
 protected override Option <IActionContext> CreateActionContext(IHumanoid player)
 {
     return(PlayerControl
            .Bind(c => c.FocusedObject)
            .Map <IEntity, IActionContext>(entity => new InteractionContext(player, entity))
            .HeadOrNone());
 }
Example #2
0
 protected virtual void OnPlayerChange(IHumanoid player)
 {
     foreach (var control in PlayerControls)
     {
         control.Player = player;
     }
 }
Example #3
0
        protected virtual void OnPlayerChange(IHumanoid player)
        {
            if (player == null)
            {
                return;
            }

            CameraManager.ToThirdPerson(player)?.ResetCamera();
        }
Example #4
0
 public static void HumanInfoPrint(IHumanoid _unit)
 {
     Console.WriteLine("Досье юнита :");
     Console.WriteLine("Имя юнита: {0}", _unit.Name);
     Console.Write("Вид речи: ");
     _unit.Say();
     Console.Write("Поведение: ");
     _unit.Order();
     Console.WriteLine();
 }
    public override void Tick()
    {
        // base.Tick(); // throws NotImplementedException

        IHumanoid human = TryLocateEnemy();

        // now the transitioning
        if (human != null)
        {
            Owner.ChangeStateByKey(typeof(AIAttackState));
        }
    }
Example #6
0
    public void IdentifyFriendOrFoe(GameObject obj) // IFF
    {
        // raycast to target, get rigidbody or parent obj, find humanoid in them or children (the topmost humanoid)
        // compare their team to ours
        // The error could be in the raycastting method which would be annoying as f**k
        // or its just not being called when nothing is hit...

        if (cursorMenu.UseIFF && customCursorBeingUsed)
        {
            int cursSpriteHashCode       = customCursor.sprite.GetHashCode();
            int normalCursSpriteHashCode = cursorMenu.NormalCursor.GetHashCode();

            if (obj)
            {
                IHumanoid hum = obj.GetComponent <IHumanoid>();
                if (hum != null)
                {
                    if (hum.TeamColor == playerHumanoid.TeamColor)
                    {
                        SetIffCursorVisual(IFFCursorType.Friendly);
                    }
                    else if (hum.TeamColor != playerHumanoid.TeamColor)
                    {
                        SetIffCursorVisual(IFFCursorType.Enemy);
                    }
                    else
                    {
                        SetIffCursorVisual(IFFCursorType.Neutral);
                    }
                }
                else
                {
                    if (cursSpriteHashCode != normalCursSpriteHashCode)
                    {
                        SetIffCursorVisual(IFFCursorType.Neutral);
                    }
                }
            }
            else
            {
                if (cursSpriteHashCode != normalCursSpriteHashCode)
                {
                    SetIffCursorVisual(IFFCursorType.Neutral);
                }
            }
        }
    }
Example #7
0
        protected override void LoadCharacter(IHumanoid character)
        {
            base.LoadCharacter(character);

            Animator = character?.Animator;

            AnimationToggle.enabled = Animator != null;
            AnimationToggle.Value   = Animator != null && Animator.enabled;

            Camera.Track(character);

            var target = FocusControlPanel.GetComponentInChildren <FocusTarget>();

            if (target != null)
            {
                FocusCamera(target);
            }
        }
Example #8
0
 protected virtual Option <IActionContext> CreateActionContext(IHumanoid player) =>
 new ActionContext(Some <IActor>(player));
Example #9
0
    public virtual void Fire(Vector3 mouseHit)
    {
        if (!hasOverheated)
        {
            if (CanFire)
            {
                isFiring = true;

                Transform rayClone = Instantiate(GameSceneSettings.Instance.GetRayPrefab, Vector3.zero,
                                                 Quaternion.identity);
                Transform rayGunFireClone = Instantiate(GameSceneSettings.Instance.GetRayHoleEffectPrefab, Vector3.zero,
                                                        Quaternion.identity);
                Transform objHit = null;

                RaycastHit[] hits = Physics.RaycastAll(firePoint.position, (mouseHit - firePoint.position).normalized,
                                                       float.MaxValue);
                Vector3 hitPos = new Vector3((int)69, (int)420, (int)1111337);

                if (hits.Length > 0)
                {
                    for (int i = 0; i < hits.Length; i++)
                    {
                        if (hits[i].collider)
                        {
                            if (hits[i].collider.attachedRigidbody)
                            {
                                if (hits[i].collider.attachedRigidbody.gameObject == gameObject)
                                {
                                    if (i == hits.Length - 1)
                                    {
                                        hitPos = mouseHit;
                                    }

                                    continue;
                                }
                                else
                                {
                                    hitPos = hits[i].point;
                                    objHit = hits[i].collider.transform;
                                    break;
                                }
                            }
                            else
                            {
                                if (hits[i].collider.gameObject == gameObject)
                                {
                                    if (i == hits.Length - 1)
                                    {
                                        hitPos = mouseHit;
                                    }

                                    continue;
                                }
                                else
                                {
                                    hitPos = hits[i].point;
                                    objHit = hits[i].collider.transform;
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    hitPos = mouseHit;
                }

                if (objHit)
                {
                    IHumanoid hitHumanoid = null;

                    if ((hitHumanoid = objHit.GetComponent <IHumanoid>()) != null)
                    {
                        hitHumanoid.TakeDamage(this);
                    }
                }

                if (hitPos == new Vector3((int)69, (int)420, (int)1111337))
                {
                    Debug.Log("Uhhhhhhhhhh" + " | " + mouseHit + " | " + firePoint.position);
                    Debug.Break();
                }

                rayGunFireClone.position    = firePoint.position;
                rayGunFireClone.localScale *= 0.5f;
                rayGunFireClone.parent      = gun;
                rayClone.position           = firePoint.position;
                rayClone.forward            = (hitPos - firePoint.position).normalized;

                Vector3 rayCloneLocalScale = rayClone.localScale;

                if (currentRayType == RayType.BasicRays)
                {
                    Transform rayPointFireClone =
                        Instantiate(GameSceneSettings.Instance.GetRayHoleEffectPrefab, Vector3.zero,
                                    Quaternion.identity);

                    rayPointFireClone.position    = hitPos;
                    rayPointFireClone.localScale *= 0.2f;
                    rayPointFireClone.parent      = GameSceneSettings.Instance.GetRayContainer;

                    rayClone.localScale = new Vector3(rayCloneLocalScale.x, rayCloneLocalScale.y,
                                                      (hitPos - firePoint.position).magnitude); // now how to move the ray...
                    rayClone.parent = GameSceneSettings.Instance.GetRayContainer;

                    Destroy(rayClone.gameObject, GameSceneSettings.Instance.GetRayLifeTime);
                }
                else if (currentRayType == RayType.FancyRays)
                {
                    float dist           = (hitPos - firePoint.position).magnitude;
                    float distMultiplier = Mathf.Clamp(dist * 0.1f, 0.1f, 10f);

                    float raySize = Mathf.Clamp(dist / 3f, 1f, 10f);

                    rayClone.localScale = new Vector3(rayClone.localScale.x, rayCloneLocalScale.y, raySize);
                    rayClone.parent     = GameSceneSettings.Instance.GetRayContainer;

                    StartCoroutine(MoveRay(rayClone, hitPos,
                                           GameSceneSettings.Instance.GetFancyRaySpeedDelta * distMultiplier));
                }


                Destroy(rayGunFireClone.gameObject, GameSceneSettings.Instance.GetRayLifeTime);
                fireTimer       = Time.time + fireDelay;
                heatPercentage += 3f;

                aceCursor.Fire();
                if (heatPercentage >= 100f)
                {
                    // Debug.Log("Overheated !");
                    hasOverheated = true;
                    heatCoolTimer = fireTimer + heatCoolDelay * 1.2f;
                }
                else
                {
                    heatCoolTimer = fireTimer + heatCoolDelay;
                }
            }
            else // do smth with gun cant fire yet delay / sight fire delay
            {
                if (indicatorCoroutine[1] == false)
                {
                    indicatorCoroutine[1] = true;
                    // Debug.Log(fireTimer + " | " + Time.time + " | " + (fireTimer - Time.time) + " | " +
                    //           (Time.time - fireTimer));
                    StartCoroutine(
                        FireNotReadyIndicatorCoroutine(sightFireDelayIndicator,
                                                       (fireTimer - Time.time) / 2f)); // Time.time - fireTimer
                    // because it waits until the gun can fire again in a nutshell
                }
            }
        }
        else // do smth with overheat coroutine
        {
            if (indicatorCoroutine[0] == false)
            {
                indicatorCoroutine[0] = true;
                StartCoroutine(OverheatedIndicatorCoroutine(ammoOverheatIndicator));
            }

            if (indicatorCoroutine[1] == false)
            {
                indicatorCoroutine[1] = true;
                // Debug.Log(fireTimer + " | " + Time.time + " | " + (fireTimer - Time.time) + " | " +
                //           (Time.time - fireTimer));
                StartCoroutine(FireNotReadyIndicatorCoroutine(sightFireDelayIndicator,
                                                              (fireDelay) / 2f)); // Time.time - fireTimer
                // because it waits until the gun can fire again in a nutshell
            }

            isFiring = false;
        }
    }
Example #10
0
    public virtual float Fire(Transform firePoint, LayerMask whatIsTarget, float fireDelay, float fireTimer)
    {
        bool canFire = Time.time > fireTimer;

        #region fire part

        if (canFire)
        {
            RaycastHelper raycasts = GameSceneSettings.Instance.RaycastFunctions;
            Vector3       hitPos   = raycasts.FromAToBRaycast(firePoint.gameObject, firePoint.forward, whatIsTarget,
                                                              out GameObject objHit);


            if (objHit != null)
            {
                IHumanoid hitHumanoid = null;
                if ((hitHumanoid = objHit.GetComponent <IHumanoid>()) != null)
                {
                    hitHumanoid.TakeDamage(Owner.StateMachineOwner.ThisStats as IDamager);
                }
            }

            Transform rayClone =
                Object.Instantiate(GameSceneSettings.Instance.GetRayPrefab, Vector3.zero, Quaternion.identity) as
                Transform;
            Transform rayGunFireClone =
                Object.Instantiate(GameSceneSettings.Instance.GetRayHoleEffectPrefab, Vector3.zero,
                                   Quaternion.identity) as Transform;

            Vector3 firePos = firePoint.position;

            rayGunFireClone.position    = firePos;
            rayGunFireClone.localScale *= 0.5f;
            rayGunFireClone.parent      = Owner.StateMachineOwner.transform;

            rayClone.position = firePos;
            rayClone.forward  = (hitPos - firePos).normalized;

            Vector3 rayCloneLocalScale = rayClone.localScale;

            if (GameSceneSettings.Instance.rayType == RayType.BasicRays)
            {
                Transform rayPointFireClone =
                    Object.Instantiate(GameSceneSettings.Instance.GetRayHoleEffectPrefab, Vector3.zero,
                                       Quaternion.identity) as Transform;

                rayPointFireClone.position    = hitPos;
                rayPointFireClone.localScale *= 0.2f;

                if (objHit == null)
                {
                    rayPointFireClone.parent = GameSceneSettings.Instance.GetRayContainer;
                }
                else
                {
                    rayPointFireClone.parent = objHit.transform;
                }

                rayClone.localScale = new Vector3(rayCloneLocalScale.x, rayCloneLocalScale.y,
                                                  (hitPos - firePoint.position).magnitude); // now how to move the ray...
                rayClone.parent = GameSceneSettings.Instance.GetRayContainer;

                Object.Destroy(rayClone.gameObject, GameSceneSettings.Instance.GetRayLifeTime);
            }
            else if (GameSceneSettings.Instance.rayType == RayType.FancyRays)
            {
                float dist           = (hitPos - firePoint.position).magnitude;
                float distMultiplier = Mathf.Clamp(dist * 0.1f, 0.1f, 10f);

                float raySize = Mathf.Clamp(dist / 3f, 1f, 10f);

                rayClone.localScale = new Vector3(rayClone.localScale.x, rayCloneLocalScale.y, raySize);
                rayClone.parent     = GameSceneSettings.Instance.GetRayContainer;

                Owner.StateMachineOwner.StartCoroutine(MoveRay(rayClone, hitPos,
                                                               GameSceneSettings.Instance.GetFancyRaySpeedDelta * distMultiplier));
            }


            Object.Destroy(rayGunFireClone.gameObject, GameSceneSettings.Instance.GetRayLifeTime);
            fireTimer = Time.time + fireDelay;
            // heatPercentage += 3f;
            //
            // if (heatPercentage >= 100f)
            // {
            //     // Debug.Log("Overheated !");
            //     hasOverheated = true;
            //     heatCoolTimer = fireTimer + heatCoolDelay * 1.2f;
            // }
            // else
            // {
            //     heatCoolTimer = fireTimer + heatCoolDelay;
            // }
        }

        #endregion

        return(fireTimer);
    }
Example #11
0
 public Humanoid(IHumanoid Obj)
 {
     Skill = Obj.Skill;
 }
Example #12
0
        /// <summary>
        /// Converts an IHumanoid to an array of HBP.SkeletonBones
        /// </summary>
        /// <returns>The srray of HBP.SkeletonBones</returns>
        /// <param name="hum">The humanoid.</param>
        public static Kinect2.IO.Skeleton To_HBP(IHumanoid hum)
        {
            Kinect2.IO.Skeleton bones = new Kinect2.IO.Skeleton(
                null,
                ulong.Parse(hum.GetInfo("userID")),
                null,
                int.Parse(hum.GetInfo("state"))
            );

            for (int i = 0; i < 25; i++)
            {
                bones[i][1] = hum[i].Center.X;
                bones[i][2] = hum[i].Center.Y;
                bones[i][3] = hum[i].Center.Z;
                bones[i][4] = hum[i].Rotation.X;
                bones[i][5] = hum[i].Rotation.Y;
                bones[i][6] = hum[i].Rotation.Z;
                bones[i][7] = hum[i].Rotation.W;
            }

            return bones;
        }
Example #13
0
 /// <summary>
 /// Put the data of the array of Vcl.Utilities.IHumanoid to the Animation_data data and returns it using
 /// the variable new_data.
 /// </summary>
 /// <param name="hums">The array of IHumanoids</param>
 /// <param name="data">The input animation data.</param>
 /// <param name="new_data">The output animation data.</param>
 public static void To_animation_data(ref IHumanoid[] hums, ref Animation_data data, out Animation_data new_data)
 {
     new_data = data;
     new_data.Reset();
     new_data.name = hums[0].Name;
     foreach (var hum in hums)
         new_data.AddFrame(new Kinect2.IO.SkeletonFrame(
             int.Parse(hum.GetInfo("frameNumber")),
             new Kinect2.IO.Skeleton[] { To_HBP(hum) },
             new float[] {0, 0, 0, 0},
             long.Parse(hum.GetInfo("timestamp"))
         ));
 }
Example #14
0
 /// <summary>
 /// Converts an Animation_data object to an array of Vcl.Utilities.IHumanoid.
 /// </summary>
 /// <param name="data">The animation data.</param>
 /// <param name="hums">The Vcl.Utilities.IHumanoid array.</param>
 public static void From_animation_data(ref Animation_data data, out IHumanoid[] hums)
 {
     hums = new IHumanoid[data.getLenght()];
     for (int i = 0; i < data.getLenght(); i++)
     {
         hums[i] = From_HBP(data.name, data.GetFrame(i), i);
         hums[i].SetInfo("frameNumber", i.ToString());
         hums[i].SetInfo("timestamp", (i * 30).ToString());
     }
 }
Example #15
0
 protected virtual void LoadCharacter(IHumanoid character)
 {
 }
 void OnEnable()
 {
     this.frameNumber = 0;
     this.hum = new K2Skeleton("Kinect2 Skeleton", new string[]
      {
         string.Format("version={0}", "1.2"),
         string.Format("frameNumber={0}", frameNumber),
         string.Format("timestamp={0}", (frameNumber * 32).ToString("X11")),
         string.Format("userCount={0}", 1),
         string.Format("userID={0}", 1),
         string.Format("state={0}", 1)
     });
     this.stream = new HumanoidStream(new IHumanoid[1] {hum });
     this.streamwriter = new SkelextV20Writer(Path.Combine(this.OutputDirectory,this.Filename));
 }
Example #17
0
 protected override void LoadCharacter(IHumanoid character)
 {
     SexMenu.Value = character.Sex.ToString();
 }