Exemplo n.º 1
0
        public void ReplaceWithGrilledChicken(MonoBehaviour m)
        {
            /*if (m.name.Contains("(Burning)")) {
             *  return;
             * }*/

            //GameObject g = ReplaceWithChicken(m);
            //g.name += "(Burning)";

            if (m is EntityAI)
            {
                EntityAI ai = m as EntityAI;

                ChangeDeathController(ai);
                KillingHandler killer = ai.my.killingHandler;
                killer.my.GibPrefab = killer.my.corpseDust;
                ai.my.killingHandler.KillMe(false);
            }
            else
            {
                GameObject featherBurst = Instantiate(Chicken.dustCorpse, m.transform.position, Quaternion.identity, m.transform.parent) as GameObject;
                Destroy(m.gameObject);
            }
            //g.GetComponent<FireTag>().Ignite();
        }
Exemplo n.º 2
0
        public virtual void ChangeFaction(EntityAI ai)
        {
            EntityAI.FactionSystem target = ai.factionSystem;
            EntityAI.FactionSystem source = Chicken.AI.factionSystem;

            if (ai.faction.Infantry.Contains(ai))
            {
                ai.faction.Infantry.Remove(ai);
            }
            foreach (var enemy in ai.TargetedBy)
            {
                if (enemy.TargetBlock.isAI)
                {
                    enemy.TargetBlock.Null();
                }
            }
            ai.faction = new Faction(null);
            Faction faction = ai.faction;

            target.faction = source.faction;
            target.primaryTargetFaction = source.primaryTargetFaction;
            target.AttackOnlyTypeOf     = FactionsController.AttackOnlyEnum.Machine;
            target.Discrimination       = FactionsController.DiscriminantEnum.Machine;
            target.Setup(ai);

            if (!FactionsController.Factions.ContainsKey(faction.Name))
            {
                FactionsController.Factions.Add(faction.Name, faction);
            }
            else
            {
                ai.faction = FactionsController.Factions[faction.Name];
            }
            //FactionsController.ChangeFaction(ai, FactionsController.Factions[faction.Name]);
        }
Exemplo n.º 3
0
    private void OnCollisionEnter(Collision col)
    {
        if (ignoreGameObjects.Contains(col.transform.gameObject))
        {
            return;
        }

        if (col.gameObject.layer == hitLayer)
        {
            EntityAI ai = col.gameObject.GetComponent <EntityAI> ();
            if (ai == null)
            {
                PlayerControls player = col.gameObject.GetComponent <PlayerControls> ();
                if (player == null)
                {
                    Debug.Log("Invalid Object set to Entity Layer: " + col.gameObject.name);
                }
                player.TakeDamage(damage);
            }
            else
            {
                ai.DamageEntity(damage);
            }
        }
        DestroySelf();
    }
Exemplo n.º 4
0
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        animator.GetComponent <EntityAI>().linkedEntity.GetComponent <CharacterController>().canChangeColor = true;
        animLinkedEntity = animator.GetComponent <EntityAI>().linkedEntity.GetComponent <Animator>();
        entity           = animator.gameObject;
        isReversed       = animator.gameObject.GetComponent <EntityAI>().isReversed;
        waypoints        = animator.gameObject.GetComponent <EntityAI>().waypoints;
        entityAgent      = animator.gameObject.GetComponent <NavMeshAgent>();
        animator.gameObject.GetComponent <FieldOfView>().target = null;
        animator.GetComponent <FieldOfView>().audible           = false;
        entityAI = animator.gameObject.GetComponent <EntityAI>();
        animator.SetBool("event", false);
        animator.SetBool("spot", false);
        animator.SetBool("targetAudible", false);

        animLinkedEntity.Rebind();
        animLinkedEntity.SetBool("Walk", true);

        animator.GetComponent <FieldOfView>().audibleTargets.Clear();

        animator.GetComponent <FieldOfView>().visible = false;
        animator.GetComponent <FieldOfView>().audible = false;

        //Without auto-barking the agent has continuous movment, the agent doesn't slow down when getting close to its destination point
        entityAgent.autoBraking = false;

        ToNextWaypoint();
    }
Exemplo n.º 5
0
        public virtual void SetVisual(EntityAI ai)
        {
            MeshFilter   filter   = ai.my.killingHandler.my.Poser.meshFilter;
            MeshRenderer render   = filter.GetComponent <MeshRenderer>();
            Transform    vis      = filter.transform;
            Transform    visPivot = vis.parent;

            ai.health = Chicken.AI.health;

            filter.mesh           = Chicken.mesh;
            render.sharedMaterial = Chicken.mat;
            if (visPivot.parent != ai.transform)
            {
                visPivot.parent.localScale = Vector3.one;
            }
            VidyaMod.MatchTransform(visPivot, Chicken.visPivot);
            VidyaMod.MatchTransform(vis, Chicken.vis);

            Transform remove = visPivot.FindChild("ArmCollider");

            if (remove)
            {
                remove.gameObject.SetActive(false);
            }
            remove = visPivot.FindChild("AttackCollider");
            if (remove)
            {
                remove.gameObject.SetActive(false);
            }
        }
Exemplo n.º 6
0
        /*
         * public void ChangeCollider(EntityAI ai) {
         *  float pct = 1f;
         *
         *  SphereCollider targetCollider = Chicken.AI.my.Collider as SphereCollider;
         *  ai.selfRighting.enabled = false;
         *  Collider target = ai.my.Collider;
         *  bool spherical = false;
         *  SphereCollider sphere = null;
         *  CapsuleCollider capsule = null;
         *
         *  if (target is SphereCollider) {
         *      spherical = true;
         *      sphere = target as SphereCollider;
         *  } else if (target is CapsuleCollider) {
         *      spherical = false;
         *      capsule = target as CapsuleCollider;
         *  } else {
         *      return;
         *  }
         *
         *  Transform t = target.transform;
         *  Vector3 startPosition = Vector3.zero;
         *  Quaternion startRotation = Quaternion.identity;
         *  Vector3 startScale = Vector3.one;
         *  Vector3 startCenter = Vector3.zero;
         *  float startRadius = 1f;
         *  float startHeight = 1f;
         *  bool isChildCollider = t != ai.transform;
         *  float maxAxisScale = 1f;
         *
         *  if (isChildCollider) {
         *      startPosition = t.localPosition;
         *      startRotation = t.localRotation;
         *      startScale = t.localScale;
         *      maxAxisScale = Mathf.Max(startScale.x, startScale.y, startScale.z);
         *  }
         *
         *  if (spherical) {
         *      startCenter = sphere.center;
         *      startRadius = sphere.radius;
         *  } else {
         *      startCenter = capsule.center;
         *      startRadius = capsule.radius;
         *      startHeight = capsule.height;
         *  }
         *
         *  if (spherical) {
         *      sphere.center = Vector3.Lerp(startCenter, isChildCollider ? targetCollider.center : targetCollider.center + targetCollider.transform.localPosition, pct);
         *      sphere.radius = Mathf.Lerp(startRadius, isChildCollider ? targetCollider.radius : targetCollider.radius * maxAxisScale, pct);
         *
         *      if (isChildCollider) {
         *          sphere.transform.localPosition = Vector3.Lerp(startPosition, targetCollider.transform.localPosition, pct);
         *          sphere.transform.localRotation = Quaternion.Slerp(startRotation, targetCollider.transform.localRotation, pct);
         *          sphere.transform.localScale = Vector3.Lerp(startScale, targetCollider.transform.localScale, pct);
         *      }
         *  } else {
         *      capsule.center = Vector3.Lerp(startCenter, isChildCollider ? targetCollider.center : targetCollider.center + targetCollider.transform.localPosition, pct);
         *      capsule.radius = Mathf.Lerp(startRadius, isChildCollider ? targetCollider.radius : targetCollider.radius * maxAxisScale, pct);
         *      capsule.height = Mathf.Lerp(startHeight, 0f, pct);
         *
         *      if (isChildCollider) {
         *          capsule.transform.localPosition = Vector3.Lerp(startPosition, targetCollider.transform.localPosition, pct);
         *          capsule.transform.localRotation = Quaternion.Slerp(startRotation, targetCollider.transform.localRotation, pct);
         *          capsule.transform.localScale = Vector3.Lerp(startScale, targetCollider.transform.localScale, pct);
         *      }
         *  }
         * }*/

        public virtual GameObject Spawn(GameObject prefab, EnemyAISimple old)
        {
            GameObject entity = Instantiate(prefab, old.transform.position, old.transform.rotation, old.transform.parent) as GameObject;

            entity.name = "Polymorphed Chicken";
            EntityAI ai = entity.GetComponent <EntityAI>();

            ai.my.basicInfo = entity.GetComponent <BasicInfo>();
            ai.my.Rigidbody = ai.my.basicInfo.Rigidbody;

            SphereCollider col = ai.my.Collider as SphereCollider;

            if (old.myCollider is SphereCollider)
            {
                col.radius = (old.myCollider as SphereCollider).radius;
            }
            else if (old.myCollider is CapsuleCollider)
            {
                col.radius = (old.myCollider as CapsuleCollider).radius;
            }

            ToChickenColliderAnimator collideranim = entity.AddComponent <ToChickenColliderAnimator>();

            collideranim.Setup(ai, Chicken.AI.my.Collider as SphereCollider);

            entity.SetActive(true);
            return(entity);
        }
Exemplo n.º 7
0
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        crystalMat       = animator.gameObject.GetComponent <EntityAI>().crystalMat;
        chasingColor     = animator.gameObject.GetComponent <EntityAI>().chasingColor;
        suspiciousColor  = animator.gameObject.GetComponent <EntityAI>().suspiciousColor;
        animLinkedEntity = animator.GetComponent <EntityAI>().linkedEntity.GetComponent <Animator>();
        entityAI         = animator.gameObject.GetComponent <EntityAI>();
        fov = animator.gameObject.GetComponent <FieldOfView>();

        visibleTargets = animator.gameObject.GetComponent <FieldOfView>().visibleTargets;
        entityAgent    = animator.gameObject.GetComponent <NavMeshAgent>();
        if (visibleTargets.Count != 0)
        {
            entityAgent.destination = visibleTargets[0].transform.position;

            lastKnownPos = visibleTargets[0].transform.position;
        }


        animator.gameObject.GetComponent <FieldOfView>().audibleTargets.Clear();
        animator.SetBool("isChasing", false);
        animator.SetBool("targetVisible", true);
        animLinkedEntity.Rebind();
        animLinkedEntity.SetBool("Run", true);
    }
Exemplo n.º 8
0
        public virtual void OnInit(GameObject enemy)
        {
            Character     = enemy;
            thisTransform = Character.transform;
            thisData      = Character.GetComponent <EntityAI>();

            //Debug.LogWarning("Default Base Input: Not Processing nothing ");
        }
Exemplo n.º 9
0
        public virtual void ChangeSounds(EntityAI ai)
        {
            RandomSoundController target = ai.my.killingHandler.my.SoundController;
            RandomSoundController source = Chicken.sounds;

            target.audioclips  = source.audioclips;
            target.audioclips2 = source.audioclips2;
            target.audioclips3 = source.audioclips3;
        }
Exemplo n.º 10
0
        public virtual void ChangeDeathController(EntityAI ai)
        {
            KillingHandler killer = ai.my.killingHandler;

            killer.my.Poser         = null;
            killer.UseGibPrefab     = true;
            killer.my.GibPrefab     = Chicken.bloodCorpse;
            killer.my.corpseDust    = Chicken.dustCorpse;
            killer.my.BloodyTexture = new Texture2D[0];
        }
Exemplo n.º 11
0
 protected override void Start()
 {
     base.Start();
     ai = this.GetComponent <EntityAI>();
     if (ai == null)
     {
         Debug.LogError("No EntityAI component attached to " + gameObject.name);
     }
     target = FindObjectOfType <Player>();
     ai.SetInitialValues(target, stats);
 }
Exemplo n.º 12
0
        public virtual void ChangePosing(EntityAI ai)
        {
            SetPoseForAI poser = ai.my.killingHandler.my.Poser;

            poser.StandingPoses                  =
                poser.FleeingPoses               =
                    poser.CowardPoses            =
                        poser.ChargingPoses      =
                            poser.AttackingPoses =
                                poser.DeathPoses = new Mesh[] { Chicken.mesh };
        }
Exemplo n.º 13
0
        public virtual void ChangeBehaviour(EntityAI ai)
        {
            EntityAI.Disposition target = ai.disposition;
            EntityAI.Disposition source = Chicken.AI.disposition;

            target.canAttack = false;
            //Destroy(ai.gameObject.GetComponent<AttackScript>());
            target.AvoidFire        = source.AvoidFire;
            target.behaviours       = source.behaviours;
            target.behavioursArray  = target.behaviours.ToArray();
            target.currentBehaviour = target.behaviours[0];
        }
        public void Setup(EntityAI e, SphereCollider c)
        {
            ai             = e;
            targetCollider = c;
            Setup(e.my.Collider, e.transform);

            e.selfRighting.enabled = false;
            //RigidbodyConstraints rc = ai.my.Rigidbody.constraints;
            //ai.my.Rigidbody.constraints = RigidbodyConstraints.None;
            //SetCollider(1f);
            //ai.my.Rigidbody.constraints = rc;
            //ResetSelfRightingAI();
        }
Exemplo n.º 15
0
        public virtual GameObject Spawn(GameObject prefab, GameObject old)
        {
            GameObject entity = Instantiate(prefab, old.transform.position, old.transform.rotation, old.transform.parent) as GameObject;

            entity.name = "Polymorphed Chicken";
            EntityAI ai = entity.GetComponent <EntityAI>();

            ai.my.basicInfo = entity.GetComponent <BasicInfo>();
            ai.my.Rigidbody = ai.my.basicInfo.Rigidbody;

            entity.SetActive(true);
            return(entity);
        }
Exemplo n.º 16
0
    public Entity(EntityCombatAI combatAI, EntityTaskAI taskAI, EntityMovementData movementData, string name = "un-named_entity", bool isFixed = false)
    {
        Name    = name;
        IsFixed = isFixed;
        SetPosition(Vector3.zero);

        EntityAI = new EntityAI(this, combatAI, taskAI);


        Inventory     = new Inventory();
        CombatManager = new EntityCombatManager(this);
        SkillTree     = new SkillTree();
        MovementData  = movementData;
    }
Exemplo n.º 17
0
    // raycast for enemy
    private bool CanSeeEntity(out EntityAI entity)
    {
        GameObject go;

        if (EntityRaycast(out go))
        {
            entity = go.GetComponent <EntityAI> ();
            if (entity != null)
            {
                return(true);
            }
        }
        entity = null;
        return(false);
    }
Exemplo n.º 18
0
        public virtual void ChangeBobbing(EntityAI ai)
        {
            EntityAI.Bob target    = ai.bob;
            EntityAI.Bob source    = Chicken.AI.bob;
            Transform    sourceVis = Chicken.AI.my.VisObject;

            target.Able       = source.Able;
            target.Amount     = source.Amount;
            target.lerpSpeed  = source.lerpSpeed;
            target.Rate       = source.Rate;
            target.startValue = source.startValue;
            target.startY     = sourceVis.localPosition.y;
            target.visPosX    = sourceVis.localPosition.x;
            target.visPosZ    = sourceVis.localPosition.z;
        }
Exemplo n.º 19
0
        public virtual void ChangeFireControl(EntityAI ai)
        {
            FireController fireControl = ai.my.killingHandler.my.fireControl;

            VidyaMod.MatchTransform(fireControl.transform, Chicken.fireControl.transform);
            SphereCollider fireCollider        = fireControl.myCollider as SphereCollider;
            FireController chickenFireControl  = Chicken.fireControl;
            SphereCollider chickenFireCollider = chickenFireControl.myCollider as SphereCollider;

            fireCollider.center          = chickenFireCollider.center;
            fireCollider.radius          = chickenFireCollider.radius;
            fireControl.destroyTimer     = chickenFireControl.destroyTimer;
            fireControl.randomAmount     = chickenFireControl.randomAmount;
            fireControl.onFireDuration   = chickenFireControl.onFireDuration;
            fireControl.fullFireDuration = fireControl.destroyTimer + fireControl.onFireDuration;
        }
Exemplo n.º 20
0
    public Entity(EntityCombatAI combatAI, EntityTaskAI taskAI, EntityMovementData movementData, string name = "un-named_entity", bool isFixed = false)
    {
        Name    = name;
        IsFixed = isFixed;
        // MoveEntity(Vector3.zero);
        Debug.Log("Base entity created");
        EntityAI = new EntityAI(this, combatAI, taskAI);


        Inventory         = new Inventory();
        CombatManager     = new EntityCombatManager(this);
        SkillTree         = new SkillTree();
        MovementData      = movementData;
        CurrentSubworldID = -1;
        IsAlive           = true;
    }
Exemplo n.º 21
0
        public override void Execute(IAIContext context)
        {
            AIContext ctx    = (AIContext)context;
            EntityAI  entity = ctx.entity;
            Entity    target = ctx.target;

            if (state == State.Start && target != ctx.lookTarget)
            {
                ctx.lookTarget = target;
                entity.LookAt(target);
            }
            else
            {
                ctx.lookTarget = null;
                entity.StopLookAt();
            }
        }
Exemplo n.º 22
0
        public GameObject ReplaceWithChicken(MonoBehaviour m)
        {
            if (m.name.Contains("Chicken"))
            {
                return(m.gameObject);
            }
            GameObject g = m.gameObject;

            m.gameObject.name = "Polymorphed Chicken";
            //Debug.Log(Chicken + ", " + m);
            GameObject featherBurst = Instantiate(Chicken.dustCorpse, m.transform.position, Quaternion.identity, m.transform.parent) as GameObject;

            VidyaMod.PlayAudio(audioSource, clip, 1f, 0.95f, 1.1f);

            if (m is EntityAI)
            {
                EntityAI ai = m as EntityAI;

                SetVisual(ai);
                ChangePosing(ai);
                ChangeDeathController(ai);
                ChangeBobbing(ai);
                ChangeFaction(ai);
                ChangeBehaviour(ai);
                ChangeSounds(ai);

                if (StatMaster.isHosting || StatMaster.isLocalSim)
                {
                    ChangeFireControl(ai);

                    ToChickenColliderAnimator collideranim = ai.gameObject.AddComponent <ToChickenColliderAnimator>();
                    collideranim.Setup(ai, Chicken.AI.my.Collider as SphereCollider);
                }
            }
            else if (m is SimpleBirdAI)
            {
                g = Spawn(Chicken.prefab, m.gameObject);
                Destroy(m.gameObject);
            }
            else
            {
                g = Spawn(Chicken.prefab, m as EnemyAISimple);
                Destroy(m.gameObject);
            }
            return(g);
        }
Exemplo n.º 23
0
 private void DamageNearbyEntities()
 {
     Collider[] hits = Physics.OverlapSphere(transform.position, radius, entityLayer);
     for (int i = 0; i < hits.Length; i++)
     {
         EntityAI ai = hits[i].transform.GetComponent <EntityAI> ();
         if (ai == null)
         {
             PlayerControls player = hits[i].transform.GetComponent <PlayerControls> ();
             if (player == null)
             {
                 Debug.LogError("Invalid Object on Entity layer: " + hits[i].transform.name);
                 return;
             }
             player.TakeDamage(damage);
             return;
         }
         ai.DamageEntity(damage);
     }
 }
Exemplo n.º 24
0
 // Use this for initialization
 void Start()
 {
     monster = GetComponent <M_Mob>();
     mobAI   = GetComponent <EntityAI>();
     initialize();
 }
Exemplo n.º 25
0
 void Start()
 {
     charAI    = GetComponent <EntityAI>();
     character = GetComponent <M_Char>();
     initialize();
 }
Exemplo n.º 26
0
 public AIContext(EntityAI entity)
 {
     this.entity = entity;
     targetList  = new List <Entity>();
 }