Exemple #1
0
    void RunPatrolState()
    {
        audioSource.clip = ZombieGroan;

        audioSource.Play();

        if (Vector3.Distance(transform.position, player.position) < findDistance)
        {
            currBehaviour = Behaviours.Combat;
        }
        else if (Vector3.Distance(points[destPoint].transform.position, transform.position) < 2f)
        {
            if (points.Length == 0)
            {
                return;
            }

            //if goes higher than the total number of waypoints -> go back to start of array
            //print("update waypoint");
            destPoint++;
            if (destPoint > points.Length - 1)
            {
                destPoint = 0;
            }
            agent.SetDestination(points[destPoint].transform.position);
        }
    }
Exemple #2
0
 protected override void GetCommands(Entity entity)
 {
     if (_cooldownCounter > 0)
     {
         _cooldownCounter--;
         return;
     }
     if (InputSource.Attack2Held)
     {
         Vector2 centerLine = InputSource.CursorPosition.normalized * 3;
         float   angle      = 30;
         _command = (attackingEntity) => {
             ConeHitbox hitbox = new ConeHitbox(attackingEntity.Position, centerLine, angle, GameInfo.EnemiesLayer);
             Debug.DrawRay(attackingEntity.Position, centerLine, Color.red, 1);
             foreach (Entity entityHit in hitbox.GetFreshHits())
             {
                 if (entityHit.IsDead)
                 {
                     continue;
                 }
                 DamageInstance inst = new DamageInstance(attackingEntity, entityHit, 5, 0);
                 inst.OnAfterApplied += (damageInstance) => {
                     if (damageInstance.IsValid)
                     {
                         damageInstance.AffectedEntity.ApplyKnockback(Behaviours.GetDirectionToTargetEntity(attackingEntity, entityHit), 2);
                         entityHit.ApplyBuff(new StunDebuff(6));
                     }
                 };
                 entityHit.TakeDamage(inst);
             }
             _cooldownCounter = CooldownTime;
         };
     }
 }
Exemple #3
0
        private void OnDealDamage(EntityDamagedEventData data)
        {
            if (data.Damage.Amount < 1)
            {
                return;
            }

            Timer.Instance.WaitForFixedUpdate(() =>
            {
                foreach (var behaviour in Behaviours.Where(
                             behaviour => behaviour.Flags.HasFlag(BehaviourFlags.BreaksOnDealDamage)).ToList())
                {
                    RemoveStack(behaviour, behaviour.StackCount);
                }

                if (!data.Damage.Flags.HasFlag(DamageFlags.DOT))
                {
                    foreach (var behaviour in Behaviours.Where(
                                 behaviour => behaviour.Flags.HasFlag(BehaviourFlags.BreaksOnDealDirectDamage)).ToList())
                    {
                        RemoveStack(behaviour, behaviour.StackCount);
                    }
                }
            });
        }
Exemple #4
0
 private void RemoveBehaviours(Func <Behaviour, bool> predicate = null)
 {
     Behaviours
     .Where(behaviour => predicate?.Invoke(behaviour) ?? true)
     .ToList()
     .ForEach(behaviour => behaviour.Remove(behaviour.StackCount));
 }
Exemple #5
0
    private void HandleOnBehaviourChanged(Behaviours newBehaviour)
    {
        target = gameObject.GetComponent <PirateBehaviour>().GetTarget();
        switch (newBehaviour)
        {
        case Behaviours.ATTACKING:
            gameObject.GetComponent <Rigidbody2D>().drag = dragValue;
            doAction = BehaviourAction;

            break;

        case Behaviours.CHASING:
            gameObject.GetComponent <Rigidbody2D>().drag = 0;
            doAction = ChaseTarget;

            Debug.Log("I see Player");

            break;

        case Behaviours.FLEEING:

            break;

        case Behaviours.PATROLING:
            gameObject.GetComponent <Rigidbody2D>().drag = dragValue;
            doAction = null;
            break;
        }
    }
Exemple #6
0
    void Start()
    {
        // Radius in which drone follows the player for attacking
        desiredDistance = 100;
        currentState    = Behaviours.GoTo;

        // initialize gunScripts array
        gunScripts = new Shooter[gun.Length];
        first      = true;

        // Add the prevent collision code
        pc = this.gameObject.AddComponent <PreventCollision>();
        pc.setActor(this.transform);

        // Spawn positon is transform at creation
        spawnPosition = this.transform;

        ///
        /// Network Code
        ///

        this.objectSync = this.GetComponent <ObjectSync>();

        ///
        /// End Network Code
        ///
    }
Exemple #7
0
        public void Apply(Behaviour behaviour, GameObject caster)
        {
            if (!behaviour.IsIgnoresImmunity &&
                Behaviours.Any(element => (element.StatusImmunity & behaviour.StatusFlags) > 0) ||
                CombatEncounter.Active == null && behaviour.IsPreventsMovement())
            {
                AnyBehaviourImmune?.Invoke(gameObject, behaviour);
                return;
            }

            BeforeBehaviourApplied(behaviour);

            var applied = Behaviours.FirstOrDefault(b => b.Id == behaviour.Id);

            if (applied != null)
            {
                ReApply(applied, behaviour);
                return;
            }

            Behaviours.Add(behaviour);
            Behaviours = Behaviours.OrderBy(b => b.RemainingDuration).ToList();

            behaviour.Removed += OnBehaviourRemoved;
            behaviour.Apply(caster, gameObject);

            AnyBehaviourApplied?.Invoke(behaviour);
            BehaviourApplied?.Invoke(behaviour);
        }
        internal WorkflowManagement(ConnectionMultiplexer mux, ITaskHandler taskHandler, WorkflowHandler workflowHandler, string identifier, IEnumerable<string> typesProcessed, ILua lua, EventHandler<Exception> exceptionHandler = null, Behaviours behaviours = Behaviours.All)
        {
            _taskHandler = taskHandler;

            _workflowHandler = workflowHandler;

            if (exceptionHandler != null)
            {
                ExceptionThrown += exceptionHandler;
            }

            _typesProcessed = typesProcessed;

            _db = mux.GetDatabase();

            _sub = mux.GetSubscriber();

            if (_typesProcessed == null || _typesProcessed.Count() == 0)
            {
                _sub.Subscribe("submittedTask", (c, v) =>
                {
                    ProcessNextTask();
                });
            }
            else
            {
                foreach(var t in _typesProcessed)
                {
                    _sub.Subscribe("submittedTask:" + t, (c, v) =>
                    {
                        ProcessNextTask(t);
                    });
                }
            }

            _sub.Subscribe("workflowFailed", (c, v) =>
            {
                ProcessNextFailedWorkflow();
            });

            _sub.Subscribe("workflowComplete", (c, v) =>
            {
                ProcessNextCompleteWorkflow();
            });

            _lua = lua;
            _lua.LoadScripts(_db, mux.GetServer("localhost:6379"));

            _identifier = identifier;

            if (behaviours.HasFlag(Behaviours.AutoRestart))
            {
                var resubmittedTasks = ResubmitTasks();

                foreach (var item in resubmittedTasks)
                {
                    Console.WriteLine("Resubmitted {0}", item);
                }
            }
        }
Exemple #9
0
 private void OnAnyEpisodeComplete(Episode episode)
 {
     foreach (var behaviour in Behaviours.Where(behaviour => behaviour.IsPreventsMovement()).ToList())
     {
         RemoveStack(behaviour, behaviour.StackCount);
     }
 }
Exemple #10
0
 void ApplyInput(Behaviours behaviour)
 {
     if (behaviour == Behaviours.Boost)
     {
         Debug.Log("boost");
         currentAcceleration = boost * accelerationSpeed;
     }
     else if (behaviour == Behaviours.Accelerate)
     {
         Accelerate();
     }
     else if (behaviour == Behaviours.Brake)
     {
         Brake();
     }
     else if (behaviour == Behaviours.Left)
     {
         steeringDirection = -1;
         Steer();
     }
     else if (behaviour == Behaviours.Right)
     {
         steeringDirection = 1;
         Steer();
     }
 }
Exemple #11
0
 public void SetSteeringWeight(SteeringType Type, int Weight)
 {
     if (Behaviours.ContainsKey(Type))
     {
         Behaviours[Type].Weight = Weight;
     }
 }
Exemple #12
0
 public void SetSteeringTarget(SteeringType Type, Unit Target)
 {
     if (Behaviours.ContainsKey(Type))
     {
         Behaviours[Type].SetTarget(Target);
     }
 }
Exemple #13
0
    private void Start()
    {
        characters = new List <Collider2D>();

        transform.GetChild(0).GetComponent <CircleCollider2D>().radius = checkRadius;
        currentBehaviour = Behaviours.PATROLING;
    }
Exemple #14
0
 public void RemoveSteering(SteeringType Type)
 {
     if (Behaviours.ContainsKey(Type))
     {
         Behaviours.Remove(Type);
     }
 }
 public void UseConfig(ChaserControllerConfig config)
 {
     if (config == null)
     {
         return;
     }
     ChaseDistance               = config.chaseDistance;
     WanderSpeedMultiplier       = config.wanderSpeedMultiplier;
     AggroRange                  = config.aggroRange;
     FramesSpentWandering        = config.framesSpentWandering;
     FramesSpentStillAfterWander = config.framesSpentStillAfterWander;
     WanderingFramesVariance     = config.wanderingFramesVariance;
     WanderingStartingCounter    = config.startingCounter;
     if (config.targettingType == TargettingModule.Technique.ByEntityType)
     {
         Entity.EntityType t = config.targetEntityType;
         _targettingModule.CheckEntityCallback = (callingEntity, entityBeingChecked) => {
             if (entityBeingChecked.IsDead)
             {
                 return(false);
             }
             if (!Behaviours.CheckIfEntityInSight(callingEntity, entityBeingChecked))
             {
                 return(false);
             }
             return(entityBeingChecked.Type == t);
         };
     }
 }
Exemple #16
0
        private void OnAnySkillUsed(SkillUseEventData data)
        {
            var behaviours = Behaviours.Where(b => b.Flags.HasFlag(BehaviourFlags.BreaksOnCast) &&
                                              b.Caster == data.Caster).ToList();

            foreach (var behaviour in behaviours)
            {
                if (!behaviour.CanBeRemovedOnCast)
                {
                    continue;
                }

                RemoveStack(behaviour, behaviour.StackCount);
            }

            // Skills triggering "AnySkillUsed" event right after behaviour is applied.

            Timer.Instance.WaitForEndOfFrame(() =>
            {
                foreach (var behaviour in behaviours)
                {
                    if (behaviour.CanBeRemovedOnCast)
                    {
                        continue;
                    }

                    behaviour.CanBeRemovedOnCast = true;
                }
            });
        }
Exemple #17
0
 public int GetStackCount(int behaviourId)
 {
     return(Behaviours
            .Where(b => b.Id == behaviourId)
            .Select(b => b.StackCount)
            .DefaultIfEmpty(0)
            .Sum());
 }
Exemple #18
0
 void RunHealState()
 {
     agent.SetDestination(healthPoint.position);
     if (Vector3.Distance(healthPoint.position, player.position) < 0.1f)
     {
         currBehaviour = Behaviours.Patrol;
     }
 }
Exemple #19
0
 // Clears the last Path
 public void ClearPath()
 {
     if (Behaviours.ContainsKey(SteeringType.PathFollowing))
     {
         PathFollowing B = (PathFollowing)Behaviours[SteeringType.PathFollowing];
         B.SetPath(null);
     }
 }
Exemple #20
0
 // Orders the Unit to move following the provided Path
 public void Move(Path Path)
 {
     if (Behaviours.ContainsKey(SteeringType.PathFollowing))
     {
         PathFollowing B = (PathFollowing)Behaviours[SteeringType.PathFollowing];
         B.SetPath(Path);
     }
 }
Exemple #21
0
        private void OnBehaviourRemoved(Behaviour behaviour)
        {
            Behaviours.Remove(behaviour);
            behaviour.Removed -= OnBehaviourRemoved;

            BehaviourRemoved?.Invoke(behaviour);
            AnyBehaviourRemoved?.Invoke(behaviour);
        }
Exemple #22
0
 /// <summary>
 ///   Clears everything, i.e. all actions, considerations, options, behaviours and AIs.
 /// </summary>
 public void ClearAll()
 {
     _aiMap.Clear();
     Behaviours.Clear();
     Options.Clear();
     Considerations.Clear();
     Actions.Clear();
 }
Exemple #23
0
    public void MoveTo(Vector3 toPos)
    {
        SteeringActive = true;

        _currentBehaviour = Behaviours.PathFinding;

        _currentToPos = toPos;
    }
Exemple #24
0
        private float getDuration(Behaviours.Behaviour newBehaviour)
        {
            float duration = 0;

            if (newBehaviour.hasLexeme())
            {
                string lexeme = "";
                switch (newBehaviour.Type)
                {
                    case Behaviours.Behaviour.eType.Face:
                        if (((Behaviours.Face)newBehaviour).Lexeme != null)
                        {
                            lexeme = ((Behaviours.Face)newBehaviour).Lexeme.Lexeme;
                        }
                        break;
                    case Behaviours.Behaviour.eType.FaceLexeme:
                        lexeme = ((Behaviours.FaceLexeme)newBehaviour).Lexeme;
                        break;
                    case Behaviours.Behaviour.eType.FaceShift:
                        if (((Behaviours.FaceShift)newBehaviour).Lexeme != null)
                        {
                            lexeme = ((Behaviours.FaceShift)newBehaviour).Lexeme.Lexeme;
                        }
                        break;
                    case Behaviours.Behaviour.eType.Gesture:
                        lexeme = ((Behaviours.Gesture)newBehaviour).Lexeme;
                        break;
                    case Behaviours.Behaviour.eType.Head:
                        lexeme = ((Behaviours.Head)newBehaviour).Lexeme;
                        break;
                }

                // TODO IO Caching!
                // get Duration
                if (lexeme != "")
                {
                    string path = "Assets\\Animations.xml";

                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(path);

                    // parse XML
                    foreach (XmlNode node in xmlDoc.ChildNodes[1])
                    {
                        if ((node.Attributes["name"] != null) && (node.Attributes["name"].Value == lexeme))
                        {
                            if (node.Attributes["duration"] != null)
                            {
                                duration = float.Parse(node.Attributes["duration"].Value);
                            }
                        }
                    }
                }
            }


            return duration;
        }
Exemple #25
0
        private void BuildButtons(StartLight light)
        {
            foreach (Statement statement in light.ScriptsList)
            {
                Button tempBtn  = new Button();
                Button tempBtn2 = new Button();
                tempBtn.Content = statement.Label;
                tempBtn.Name    = "exec_" + statement.Identity;
                tempBtn.ToolTip = statement.Description;
                switch (statement.OperationType.ToLowerInvariant())
                {
                case "ssh":
                    if (statement.ServerName.ToSafeString() != "")
                    {
                        tempBtn.Click += new RoutedEventHandler((e, o) =>
                                                                Behaviours.ExecScriptWithLog()(
                                                                    light.ScriptsList[Convert.ToInt16(tempBtn.Name.Split('_')[1])],
                                                                    txtTailPars.Text,
                                                                    execBar,
                                                                    txtBox,
                                                                    light.ScriptsList[Convert.ToInt16(tempBtn.Name.Split('_')[1])].ServerName,
                                                                    light.ScriptsList[Convert.ToInt16(tempBtn.Name.Split('_')[1])].ServerUser,
                                                                    light.ScriptsList[Convert.ToInt16(tempBtn.Name.Split('_')[1])].ServerPassword));
                    }
                    else
                    {
                        tempBtn.Click += new RoutedEventHandler((e, o) =>
                                                                Behaviours.ExecScriptWithLog()(
                                                                    light.ScriptsList[Convert.ToInt16(tempBtn.Name.Split('_')[1])],
                                                                    txtTailPars.Text,
                                                                    execBar,
                                                                    txtBox,
                                                                    light.ServerName,
                                                                    light.ServerUser,
                                                                    light.ServerPassword));
                    }
                    break;

                case "localosstatement":
                    tempBtn.Click += new RoutedEventHandler((e, o) =>
                                                            Behaviours.StartProcess()(statement, txtTailPars.Text, txtBox, this.execBar));
                    break;

                default:
                    break;
                }

                btnMain.Children.Add(tempBtn);

                tempBtn2.Content = "script";
                tempBtn2.Name    = "script_" + statement.Identity;
                tempBtn2.Click  += new RoutedEventHandler(
                    (e, o) => MessageBox.Show(light.ScriptsList[Convert.ToInt16(tempBtn.Name.Split('_')[1])].ScriptToLaunch + " " + light.ScriptsList[Convert.ToInt16(tempBtn.Name.Split('_')[1])].Parameters + txtTailPars.Text)

                    );
                btnMainScripts.Children.Add(tempBtn2);
            }
        }
Exemple #26
0
    public SmokeBomb()
        : base(name, description, damage, timeToCast, abilityDuration, cooldown)
    {
        Behaviours.Add(new Snare(effectDuration, slow, slowPrefab));

        Behaviours.Add(new Range(range, travelSpeed, damage, dotPrefab));

        Behaviours.Add(new DamageOverTime(effectDuration, damage, tickDuration, dotPrefab));
    }
Exemple #27
0
 public XElement ToXml( )
 {
     return(new XElement(
                @"Layer",
                new XAttribute(@"Name", Name),
                _properties.SerializeToXml( ),
                Behaviours.ToXml(  ),
                new XElement(@"Editors", Items.Select(i => i.ToXml( )))));
 }
Exemple #28
0
 private void OnAnyEntityDied(EntityDiedEventData data)
 {
     foreach (var behaviour in Behaviours.Where(behaviour =>
                                                behaviour.Flags.HasFlag(BehaviourFlags.BreaksOnCasterDeath) &&
                                                behaviour.Caster == data.Victim).ToList())
     {
         RemoveStack(behaviour, behaviour.StackCount);
     }
 }
Exemple #29
0
        public void Update(Bot bot)
        {
            bot.acceleration += Behaviours.Seek(bot);

            if (bot.GetStaticMap().IsLineOfSight(bot.GetPosition(), bot.Enemy.GetPosition()))
            {
                bot.SetState(new Pursue());
            }
        }
Exemple #30
0
        protected override void Awake()
        {
            base.Awake();

            name_string = "Gatherer Car";

            Behaviours.Add(new BehaviourGatherer(this, gather_frequency, gather_amount));
            Behaviours.Add(new BehaviourPlayerHealthPoints(this));
            //Behaviours.Add (new BehaviourUpgradable(this, upgrade, upgrade_cost));
        }
Exemple #31
0
    // Update is called once per frame
    void Update()
    {
        if (healthScript.getHealth() < 25)
        {
            currBehaviour = Behaviours.Heal;
        }
        RunBehaviours();

        //agent.SetDestination(points[destPoint].transform.position);
    }
Exemple #32
0
    public SwordThrust(Animator animator, int index)
        : base(name, description, effectDamage, timeToCast, effectDuration, cooldown)
    {
        this.Anim  = animator;
        this.Index = index;

        Behaviours.Add(new Meele(range, effectDamage, sword));

        Behaviours.Add(new DamageOverTime(effectDuration, dotDamage, dotDuration, dot));
    }
 /// <summary>
 /// Instantiate a new workflow manager, able to submit workflows and process tasks.
 /// </summary>
 /// <param name="mux"></param>
 /// <param name="taskHandler"></param>
 /// <param name="workflowHandler"></param>
 /// <param name="identifier"></param>
 /// <param name="exceptionHandler"></param>
 /// <param name="lowestPriority">
 /// The lowest priority task this instance will consider. High priority is given a score of 0; lowest priority should be given 
 /// a score > 0. Defaults to 100. Note that you should have at least one instance able to cover the whole priority range you
 /// submit at.
 /// </param>
 /// <param name="typesProcessed"></param>
 /// <param name="behaviours"></param>
 public WorkflowManagement(ConnectionMultiplexer mux, ITaskHandler taskHandler, WorkflowHandler workflowHandler, string identifier, EventHandler<Exception> exceptionHandler, int lowestPriority = 100, IEnumerable<string> typesProcessed = null, Behaviours behaviours = Behaviours.All)
                 : this(mux, taskHandler, workflowHandler, identifier, typesProcessed, new Lua(lowestPriority), exceptionHandler, behaviours)
 {
     
 }
Exemple #34
0
 public void SetMeToKill()
 {
     currentBehaviour = Behaviours.Kill;
 }
Exemple #35
0
    IEnumerator AdvanceBehaviour()
    {
        if (actionCount <= 0 && currentBehaviour != Behaviours.Kill){
            actionCount = Random.Range(1, 5);
            currentBehaviour = (Behaviours)Random.Range(0, 2);
        }

        while (actionCount > 0){
            switch (currentBehaviour){
                case Behaviours.Walk:
                    yield return StartCoroutine(Walk());
                    break;
                case Behaviours.Turn:
                    yield return StartCoroutine(Turn());
                    break;
                case Behaviours.Stand:
                    yield return StartCoroutine(Stand());
                    break;
                case Behaviours.Kill:
                    yield return StartCoroutine(Kill());
                    break;
            }
        }

        isBehaving = false;
    }
    // Go back to original target and state
    public void TriggerLeave(Collider Object)
    {
        if (Network.peerType == NetworkPeerType.Client && !GlobalSettings.SinglePlayer)
            return;

        // In case object no longer exists or target leaves
        // go back to main target
        if (Object == null || Object.transform == target)
        {
            // If our previous target is no longer available return ro spawn position
            if (prevTarget == null)
            {
                target = spawnPosition;
                currentState = prevState;
            }
            else
            {
                target = prevTarget;
                currentState = prevState;
            }
        }
    }
    void Start()
    {
        // Radius in which drone follows the player for attacking
        desiredDistance = 100;
        currentState = Behaviours.GoTo;

        // initialize gunScripts array
        gunScripts = new Shooter[gun.Length];
        first = true;

        // Add the prevent collision code
        pc = this.gameObject.AddComponent<PreventCollision>();
        pc.setActor(this.transform);

        // Spawn positon is transform at creation
        spawnPosition = this.transform;

        ///
        /// Network Code
        ///

        this.objectSync = this.GetComponent<ObjectSync>();

        ///
        /// End Network Code
        ///
    }
    public void TriggerEnter(Collider Object)
    {
        if (Network.peerType == NetworkPeerType.Client && !GlobalSettings.SinglePlayer)
            return;

        //  TODO change in some important condition like:
        //  - enough health
        //  - not state defending
        //  - some other?

        if (isOpponent(Object))
        {
            // TODO Only chase if this object is closer than current target

            // In csse the mothership is the new target
            // set the desired distance to mothership and
            // the radius in which to begin shooting
            if (Object.transform.tag == "Mothership")
            {

                if (currentState != Behaviours.Chase)
                {
                    prevTarget = target;
                    prevState = currentState;
                }
                target = Object.transform;

                currentState = Behaviours.Chase;
                desiredDistance = 700;
                shootRadius = 900;
            }
            // If the new target is not the mothership, make sure it
            // is close enough to start responding to it

            else if ((Object.transform.position - transform.position).magnitude < 700)
            {

                if (currentState != Behaviours.Chase)
                {
                    prevTarget = target;
                    prevState = currentState;
                }
                target = Object.transform;

                currentState = Behaviours.Chase;
                // check if the distance to the opponent is close enoug
                desiredDistance = 100;
                shootRadius = 200;
            }
        }
    }
Exemple #39
0
 public void GoKillPlayer(GameObject player)
 {
     player = playerCharacter;
     currentBehaviour = Behaviours.Kill;
     actionCount = 1;
 }
Exemple #40
0
    IEnumerator Walk()
    {
        // if up - y++
        // if left x--
        // if right x++
        // if down y--

        isWalking = true;
        StartCoroutine(AnimateWalk());

        if (currentDirection == Directions.Up && CheckIfCanMove(x, y + 1)){

            yield return StartCoroutine(moveToSquare(mapLoader.MapCoords[x, y+1].position,
                                                     x,
                                                     y+1));
        }
        else if(currentDirection == Directions.Down && CheckIfCanMove(x, y - 1)){
            yield return StartCoroutine(moveToSquare(mapLoader.MapCoords[x, y - 1].position,
                                        x,
                                        y-1));
        }
        else if(currentDirection == Directions.Left && CheckIfCanMove(x - 1, y)){
            yield return StartCoroutine(moveToSquare(mapLoader.MapCoords[x-1, y].position,
                                        x-1,
                                        y));
        }
        else if(currentDirection == Directions.Right && CheckIfCanMove(x + 1, y)){
            yield return StartCoroutine(moveToSquare(mapLoader.MapCoords[x+1, y].position,
                                        x+1,
                                        y));
        }
        else{
            currentBehaviour = Behaviours.Turn;
        }
        isWalking = false;
    }
    // Use this for initialization
    void Start()
    {
        viewAngleRad = viewAngleDeg*Mathf.Deg2Rad;
        controller = transform.GetComponent<CharacterController>();
        Random.seed = 1;

        //Default behaviour
        currBehaviour = new BWander(this);

        //Default destination
        destination = transform.position;

        wanderTarget = new Vector3(0,0,0);
        velocity = new Vector3(0,0,0);

        //Set up obstacle avoidance feelers
        feelers = new Vector3[5];
        feelers[0] = new Vector3(0,0,1);
        feelers[1] = Quaternion.Euler(0,22,0)* feelers[0];
        feelers[2] = Quaternion.Euler(0,-22,0)* feelers[0];
        feelers[3] = Quaternion.Euler(0,45,0)* feelers[0];
        feelers[4] = Quaternion.Euler(0,-45,0)* feelers[0];

        //Initialize enemies
        GameObject tmp = GameObject.Find("EnemySpartan");
        if (tmp != null){
            spartan=tmp.transform;
            enemyStatus = spartan.GetComponent(typeof(AIStatus)) as AIStatus;
        }

        tmp = GameObject.Find("TheDragon");
        if (tmp != null){
            dragon=tmp.transform;
        }

        //Turn off the gun for now
        gun.gameObject.SetActiveRecursively(false);
    }
Exemple #42
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="behaviour">Behaviour to start.</param>
 /// <param name="playbackTime">Current playback time of this behaviour. Delay of the current time from the planned start time.</param>
 private void StartBehaviour(Behaviours.Behaviour behaviour, float playbackTime)
 {
     // TODO
 }
Exemple #43
0
    // Use this for initialization
    void Start()
    {
        spriteRenderer.sprite = frontAnimations[0];

        currentBehaviour = (Behaviours)Random.Range(0, 2);
        currentDirection = (Directions)Random.Range(0, 3);
        actionCount = Random.Range(0, 5);

        if (!mapLoader){
            mapLoader = GameObject.Find("Map Loader").GetComponent<MapLoader>();
        }

        playerCharacter = GameObject.Find("PlayerSprite(Clone)");
    }