Example #1
0
 /// <summary>
 /// Complete Declaration for StandardMob
 /// </summary>
 /// <param name="x">X position in the world</param>
 /// <param name="y">Y position in the world</param>
 /// <param name="textureName">Name of the texture</param>
 /// <param name="type">AIType to use for the Mob</param>
 public StandardMob(float x, float y, int layer, Texture textureName, AIBase.AIType type, float width = 16, float height = 16) : base(x, y, layer, textureName, width, height)
 {
     mobAI = new AIBase(this)
     {
         type = type
     };
 }
Example #2
0
 public StandardMob(float x, float y, Texture textureName, AIBase.AIType type = AIBase.AIType.Passive) : base(x, y, textureName)
 {
     mobAI = new AIBase(this)
     {
         type = type
     };
 }
Example #3
0
    public void GetStart(GameObject obj)
    {
        EnemyObj = obj;

        //提高硬值
        if (!isAcing)
        {
            isAcing = true;
            GetComponent <RoleDate>().addYZ(addYZNum);
            gameBody = GetComponent <GameBody>();
            _aiBase  = GetComponent <AIBase>();

            if (RunName == "" || !gameBody.GetDB().animation.HasAnimation(RunName) || !gameBody.GetDB().animation.HasAnimation(AtkName))
            {
                AcOver();
                return;
            }
            oldRunName   = gameBody.GetRunName();
            oldRunSpeedX = gameBody.maxSpeedX;
            //print("---------------->AtkName    " + AtkName + "   RunName  " + RunName+ "     oldRunName  "+ oldRunName);

            gameBody.RunACChange(RunName, moveSpeedX);

            if (AudioRunCut)
            {
                AudioRunCut.Play();
            }
        }
    }
Example #4
0
	void Awake()
	{
		coords = new int[2];
		lastCoords = new int[2];
		canSee = new List<Player> ();
		m_AttackAxisInUse = false; 
		tr = transform;
		CombatMode = false; 
		pos = transform.position;
		currentPath = new List<Vector2> ();
		controller = GetComponent<PlayerController>();
		workingAI = new AIBase (this);
		lastInput = Vector3.one;
		playerStats = new PlayerStats (); 
		currentState = CharacterState.Still;
		controller.SetSpeed (playerStats.GetSpeed());
		isStuck = 0;
		canAttack = "Enemy";
		coolDownLimit = playerStats.GetAttackCooldown();
		currentAttackCoolDown = 0; 
		inventory = GetComponent<InventoryBase>();
		weaponController = GetComponentInChildren<WeaponController> ();
		anim = GetComponent<Animator>(); 
		spriteRen = GetComponent<SpriteRenderer> ();
		//seeker = GetComponent<Seeker> (); 

	}
Example #5
0
 public void  Setup(EnemyModel model)
 {
     base.Setup();
     Status.Setup(model);
     ai_         = GetAI(model.AiId);
     enemy_model = model;
 }
Example #6
0
    public AICheckStatus(AIBase aiBase)
    {
        this.aiBase = aiBase;
        transform   = aiBase.transform;

        playArea = EnemyManager.GetPlayArea();
    }
Example #7
0
    public void Init()
    {
        if (isInit == true)
        {
            return;
        }
        isInit = true;

        thisTransform = this.transform;
        AIBase        = thisTransform.GetComponent <AIBase>();
        health        = thisTransform.GetComponent <Health>();
        if (abilityManager == null)
        {
            abilityManager = GameObject.FindGameObjectWithTag("AbilityManager").GetComponent <AbilityManager>();
        }

        for (int i = 0; i < abilityNames.Length; i++)
        {
            abilityIndexes.Add(abilityManager.GetAbilityIndex(abilityNames[i]));
        }

        for (int i = 0; i < abilityIndexes.Count; i++)
        {
            InitAbility(abilityIndexes[i]); //kan ju inte bara init denna coz det är ett kinda abstrakt värde, init ska ske på denna unitspellhandlern själv
        }
        Reset();
        AIBase.LoadValidSpellIndexes(); //viktigt att denne kallar, AIbase klarar ju inte av det själv :/ men den hinner inte fixa alla abilitylistor innan den vill retrieva annars
    }
Example #8
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="teamId"></param>
    void OnAIDied(int teamId)
    {
        AIBase ai = m_AIs[teamId];

        // move ai from alive buffer to leaderboard
        m_AliveAIs.Remove(ai);
        m_Leaderboard.Insert(0, ai);

        // deactivate ai
        ai.XKActive = false;
        XKLog.Log("Info", string.Format("An AI has died: {0} ({1}) ", ai.GetType().ToString(), ai.TeamId));

        if (m_AliveAIs.Count == 1)
        {
            // store the winner
            m_Leaderboard.Insert(0, m_AliveAIs[0]);

            // deactivate gameboard, no need to keep it active
            XKActive = false;
            XKLog.Log("Info", string.Format("The last AI has died, the winner is: {0} ({1}) ", m_AliveAIs[0].GetType().ToString(), m_AliveAIs[0].TeamId));

            // announce the game is over to whom ants to listen
            if (OnGameOver != null)
            {
                OnGameOver(m_Leaderboard);
            }
        }
    }
Example #9
0
    new void Start()
    {
        base.Start();
        this.primaryAttack = new Attack
                             (
            this.gameObject,
            Attack.AttackType.MeleeAttack,
            10f, // Damage
            3f,  // Rate of Fire
            1f   // Range
                             );

        maxSpeed      = 12f;
        hspeed        = .1f;
        this.faction  = Factions.Parasite;
        this.gibColor = new Color32(0, 255, 0, 255);

        this.secondaryAttack = new Attack
                                   (this.gameObject,
                                   Attack.AttackType.ProjectileAttack,
                                   2f,
                                   1f,
                                   10f
                                   );
        this.AI = this.gameObject.AddComponent <AIBase>();
    }
Example #10
0
 public void OnAdd(AIBase AI)
 {
     AI.Animator.SetBool("IsIdle", false);
     AI.Animator.SetBool("IsWalking", false);
     AI.Animator.SetBool("IsRunning", true);
     AI.NavAgent.speed = 10;
 }
Example #11
0
    public void Update()
    {
        AIBase followTaget = target;

        if (followTaget != null && followTaget.transform != null)
        {
            Transform targetTran  = followTaget.transform;
            Vector3   eulerAngles = targetTran.eulerAngles;

            if (Input.GetMouseButton(1))
            {
                angleX += Input.GetAxis("Mouse X") * mouseRotateSpeed.x * Time.deltaTime;
                angleY -= Input.GetAxis("Mouse Y") * mouseRotateSpeed.y * Time.deltaTime;
                angleY  = ClampAngle(angleY, yAngleMin, yAngleMax);
            }
            Quaternion rotation = Quaternion.Euler(angleY, angleX, 0);


            float scrollValue = Input.GetAxis("Mouse ScrollWheel");

            distance -= scrollValue;


            //以跟随目标为中心,向指定欧拉角方向偏移一定距离, 得出当前摄像机应该要在的坐标
            Vector3 targetPos = rotation * new Vector3(0, yOffset, -distance) + targetTran.position;
            Camera.main.transform.position = targetPos;
            Camera.main.transform.rotation = rotation;
        }
    }
Example #12
0
    /// <summary>
    /// 添加状态
    /// </summary>
    public void AddState(FSMState s, AIBase ctrl)
    {
        // Check for Null reference before deleting
        if (s == null)
        {
            Debug.LogError("FSM ERROR: Null reference is not allowed");
        }

        s.FSM = this;//给每个状态的 FSM 赋值

        s.M_CTRL = ctrl;//每个状态得到controller

        // First State inserted is also the Initial state,
        //   the state the machine is in when the simulation begins
        if (states.Count == 0)
        {
            states.Add(s);
            return;
        }

        // Add the state to the List if it's not inside it
        foreach (FSMState state in states)
        {
            if (state.ID == s.ID)
            {
                Debug.LogError("FSM ERROR: Impossible to add state " + s.ID.ToString() +
                               " because state has already been added");
                return;
            }
        }
        states.Add(s);
    }
Example #13
0
 public TurnInfo(AIBase aibase)
 {
     turnInMotion    = false;
     ai              = aibase;
     gridElement     = aibase.gridElement;
     initialLocation = gridElement.position;
 }
Example #14
0
    protected override void CollisionEnter(Collision other)
    {
        M_Rigidbody.Sleep();

        BulletMark bulletMark = other.gameObject.GetComponent <BulletMark>();
        AIBase     ai         = other.gameObject.GetComponentInParent <AIBase>();

        // 攻击环境物体.
        if (bulletMark != null)
        {
            bulletMark.CreateBulletMark(hit);
            bulletMark.Hp -= Damage;
        }

        // 攻击AI角色.
        else if (ai != null)
        {
            // 头部伤害加倍.
            if (other.gameObject.name == "Head")
            {
                ai.Life -= 2 * Damage;
                ai.HitHeadState();
            }
            else
            {
                ai.Life -= Damage;
                ai.HitNormalState();
            }

            ai.PlayEffect(hit);
        }

        gameObject.SetActive(false);
    }
Example #15
0
    public virtual void fixedLogic()
    {
        if (popAI)
        {
            popAI = false;
            ai.Pop();
        }
        if (nextAI != null)
        {
            ai.Push(nextAI);
            nextAI = null;
        }

        while (ai.Count > 0 && !ai.Peek().isValid())
        {
            ai.Pop();
        }
        if (ai.Count > 0)
        {
            AIBase newAI = ai.Peek().fixedLogicTick();
            if (newAI != null)
            {
                addAIState(newAI);
            }
        }

        if (characterStats.getHealth() <= 0)
        {
            Destroy(gameObject);
        }
    }
Example #16
0
    public void OnAttackTarget(GameObject gameObject, float delay)
    {
        if (isHaveBomb)
        {
            if (bombPrefab != null)
            {
                target = gameObject;
                //Invoke("Do", delay-0.1f);
                //GameObject projectile = Instantiate(bombPrefab, spawnPosition.position, Quaternion.identity) as GameObject;
                //projectile.transform.LookAt(target.transform.position);
                //projectile.GetComponent<Rigidbody>().AddForce(projectile.transform.forward * 1000);

                GameObject projectile = Instantiate(bombPrefab, spawnPosition.position, Quaternion.identity) as GameObject;
                Vector3    pos        = new Vector3(target.transform.position.x, Random.Range(0.0f, 2.0f), target.transform.position.z);
                projectile.transform.LookAt(pos);
                projectile.GetComponent <HyperbitProjectileScript>().isPlaying        = true;
                projectile.GetComponent <HyperbitProjectileScript>().attackTargetType = target.gameObject.tag;
            }
        }
        else
        {
            AIBase aIBase = gameObject.GetComponent <AIBase>();
            if (aIBase)
            {
                aIBase.OnHited(this.gameObject);
            }
        }
    }
Example #17
0
        public Player(int id, Color primary, int ai)
        {
            Id             = id;
            PrimaryColor   = primary;
            SecondaryColor = GameModel.RandomColor(new Color[] { PrimaryColor }, 300);

            Countries  = new List <Country>();
            Continents = new List <Continent>();
            if (ai == 0)
            {
                AI = new AI_FullRandom(this);
            }
            else if (ai == 1)
            {
                AI = new AI_OneSafeAttack(this);
            }
            else if (ai == 2)
            {
                AI = new AI_MultipleSafeAttacks(this);
            }
            else if (ai == 3)
            {
                AI = new AI_SmartRandom(this);
            }
            else if (ai == 4)
            {
                AI = new AI_AttackWhenDense(this);
            }
        }
Example #18
0
    // Use this for initialization
    void Start()
    {
        if (!photonView.isMine)
        {
            Destroy(GetComponent <ThirdPersonController> ());
            Destroy(GetComponent <ThirdPersonCamera> ());
            Destroy(GetComponent <MouseLook> ());
            GetComponent <Rigidbody> ().isKinematic = true;
        }
        else
        {
            cameraController = GetComponent <ThirdPersonCamera> ();
            isAi             = cameraController == null;
        }
        AIBase comp = GetComponent <AIBase> ();

        isAi = comp != null;

        correctPlayerPos = transform.position;
        myCollider       = collider;

        centerOffset = capsule.bounds.center - myTransform.position;
        headOffset   = centerOffset;
        headOffset.y = capsule.bounds.max.y - myTransform.position.y;

        distToGround = capsule.height / 2 - capsule.center.y;
        charMan      = GetComponent <CharacteristicManager> ();
        charMan.Init();
        health = charMan.GetIntChar(CharacteristicList.MAXHEALTH);
        //Debug.Log (distToGround);
    }
Example #19
0
 public void Update(AIBase AI)
 {
     if (!AI.NavAgent.hasPath)
     {
         AI.NavAgent.SetDestination(HomePos);
     }
 }
Example #20
0
    virtual protected void DoDestroy()
    {
        aiBase = gameObject.transform.parent.GetComponentInChildren <AIBase>();

        GameObject patrolObject = aiBase.GetPatrolObject();

        if (aiBase != null)
        {
            Destroy(patrolObject);
        }

        SpawnManager spawnManager = GetComponentInParent <SpawnManager>();

        if (spawnManager != null)
        {
            AIBase aiBase = spawnManager.GetSpanwerAI();

            if (aiBase != null)
            {
                aiBase.DeductSpawn();
            }
        }

        GameObject temp = Instantiate(Resources.Load("General/EnemyDestroy")) as GameObject;

        temp.transform.position = transform.position;

        spriteRenderer.color = new Color(1f, 1f, 1f, 0f);
        Destroy(gameObject.transform.parent.gameObject);
    }
Example #21
0
    private void GradualSpeedUp(AIBase r)
    {
        var targetTime = r.velocity.magnitude / GameManager.instance.globalTimeMult;

        StartCoroutine(Commons.DoUntil(() => r.maxSpeed /= 0.9f,
                                       () => r.maxSpeed > targetTime));
    }
Example #22
0
    private void GradualSlowDown(AIBase r)
    {
        var targetTime = r.velocity.magnitude * GameManager.instance.globalTimeMult;

        StartCoroutine(Commons.DoUntil(() => r.maxSpeed *= 0.98f,
                                       () => r.maxSpeed < targetTime));
    }
Example #23
0
 public void DeRegisterAI(AIBase ai)
 {
     if (_lumpAi.Contains(ai))
     {
         _lumpAi.Remove(ai);
     }
 }
Example #24
0
 public RentableBot(int virtualID, Room room, AIBase ai, int ownerID, char gender, int timeLeft)
     : base(virtualID, ai, room)
 {
     this.OwnerID  = ownerID;
     this.Gender   = gender;
     this.TimeLeft = timeLeft;
 }
Example #25
0
        /// <summary>
        /// creates and initializes all base A.I.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            //  Entry patrol update function in AI
            AIBase aiSearch = new AIBase();

            aiSearch.Updating +=
                new EventHandler <AIBase.AIUpdateEventArgs>(OnSearchUpdateEvent);
            indexAiSearch = AIContext.AddAI("Search", aiSearch);

            //  Entry move update function in AI
            AIBase aiMove = new AIBase();

            aiMove.Updating +=
                new EventHandler <AIBase.AIUpdateEventArgs>(OnMoveUpdateEvent);
            indexAiMove = AIContext.AddAI("Move", aiMove);

            //  Entry attack update function in AI
            AIBase aiAttack = new AIBase();

            aiAttack.Updating +=
                new EventHandler <AIBase.AIUpdateEventArgs>(OnAttackUpdateEvent);
            indexAiAttack = AIContext.AddAI("Attack", aiAttack);

            //  Entry left turn update function in AI
            AIBase aiTurnLeft = new AIBase();

            aiTurnLeft.Updating +=
                new EventHandler <AIBase.AIUpdateEventArgs>(OnTurnLeftUpdateEvent);
            indexAiTurnLeft = AIContext.AddAI("TurnLeft", aiTurnLeft);

            //  Entry right turn update function in AI
            AIBase aiTurnRight = new AIBase();

            aiTurnRight.Updating +=
                new EventHandler <AIBase.AIUpdateEventArgs>(OnTurnRightUpdateEvent);
            indexAiTurnRight = AIContext.AddAI("TurnRight", aiTurnRight);

            WorldTransform = SpawnPoint;

            //  Remove a collision
            if (colLayerEnemyMech != null)
            {
                if (colLayerEnemyMech.IsContain(Collide))
                {
                    colLayerEnemyMech.RemoveCollide(Collide);
                }
            }

            //  Remove a collision
            if (colLayerAllMech != null)
            {
                if (colLayerAllMech.IsContain(Collide))
                {
                    colLayerAllMech.RemoveCollide(Collide);
                }
            }
        }
Example #26
0
    public AIMovement(AIBase aiBase)
    {
        this.aiBase = aiBase;

        playArea = EnemyManager.GetPlayArea();

        GetRandomDirection();
    }
Example #27
0
 public void changeAIState(AIBase state)
 {
     if (ai.Count > 1)
     {
         popAI = true;
     }
     addAIState(state);
 }
Example #28
0
 private void DeInitAI()
 {
     if (this.m_AIBase != null)
     {
         this.m_AIBase.DeInit();
         this.m_AIBase = null;
     }
 }
Example #29
0
    private void Start()
    {
        attr        = GetComponent <NpcAttribute>();
        aiBase      = GetComponent <AIBase>();
        vcontroller = GetComponent <MoveController>().vcontroller;

        gameObject.AddComponent <DebugServerPos>();
    }
Example #30
0
	public AIAndAttack(Player _player, AIBase _standardAI) : base(_player)
	{
		standardAI = _standardAI; 
		currentAI = standardAI;
		currentState = AIState.Standard; 
		maxCooldown = 2;
		searchCoolDown = 0.0f; 
		target = null; 
	}
Example #31
0
 public AnimatedSprite(string TextureName, int rows, int columns, int xIn, int yIn, AIBase ai, BaseManager manIn)
 {
     animate         = new Animation(TextureName, rows, columns);
     AI              = ai;
     xy              = new Point(xIn, yIn);
     Manager         = manIn;
     Buffs           = new BuffHandler();
     damageIndicator = new DamageIndicator();
 }
Example #32
0
 virtual protected void Awake()
 {
     parentObject    = transform.parent.gameObject;
     m_movementModel = gameObject.GetComponentInParent <CharacterMovementModel>();
     aiBase          = transform.parent.GetComponentInChildren <AIBase>();
     spriteRenderer  = parentObject.GetComponentInChildren <SpriteRenderer>();
     speechBubble    = transform.parent.GetComponentInChildren <SpeechBubble>();
     maxHealth       = health;
 }
Example #33
0
    protected override void OnAwake()
    {
        // Retrieves the desired components
        base.OnAwake();
        _aiComponent = GetComponentInParent<AIBase>();
        _independentControl = GameObject.FindGameObjectWithTag(Tags.GameController).GetComponent<GameControllerIndependentControl>();

        // Registers itself to the AIBase events
        _aiComponent.AddListener(this);
    }
Example #34
0
		//public Animator anima;

		void Start ()
		{
				states = GetComponents<AIBase> ();
				foreach (AIBase state in states) {
						state.enabled = false;
				}
				currentState = states [0];
				currentState.enabled = true;
				//	anima = GetComponentInChildren<Animator> ();
//				attackState = GetComponentInParent<Attack> ();
//				fleeState = GetComponentInParent<FleeState> ();
//				currentState.enabled = true;
	
		}
Example #35
0
    public void OnBeingScared(AIBase enemy, GameObject scaringObject, int scaringSize)
    {
        // Sets the eyes' color to the scared one
        _targetEyeColor = eyesScaredColor;

        // Creates the scared prefab
        GameObject scaredEffect = Instantiate(scaredEffectPrefab, scaredEffectTransform.position, scaredEffectTransform.rotation) as GameObject;
        ParticleSystem[] systems = scaredEffect.GetComponentsInChildren<ParticleSystem>();
        foreach (ParticleSystem sys in systems) {
            sys.randomSeed = (uint)UnityEngine.Random.Range(0, int.MaxValue);
            sys.Simulate(0, true, true);
            sys.Play();
        }
        scaredEffect.transform.parent = scaredEffectTransform;
    }
Example #36
0
	public override void CalculateAction()
	{
		if (currentPlayer.canSee.Count > 0 && target == null) 
		{
			foreach (Player seen in currentPlayer.canSee) 
			{
				if (seen.tag.Contains (currentPlayer.canAttack)) {
					currentState = AIState.Attack;
					int pickTarget = Random.Range (0, currentPlayer.canSee.Count);
					target = seen;//currentPlayer.canSee [pickTarget];
					currentAI = new AIFollowAndAttack (currentPlayer, target);
					break; 
				}
			}
		}

		if (target != null) 
		{	
			if (target.playerStats.health <= 0) 
			{
				target = null;
				currentState = AIState.Standard;
				currentAI = standardAI;
			}

			if (!currentPlayer.canSee.Contains (target) && searchCoolDown < 0) 
			{
				ActivateTrigger (target.lastCoords);
				target = null; 
			} 
			else if (!currentPlayer.canSee.Contains (target) && searchCoolDown >= 0) 
			{
				searchCoolDown -= Time.deltaTime; 
			}
			else 
			{ 
				searchCoolDown = maxCooldown; 
			}
		}


		BeingTriggered (); 
		currentAI.CalculateAction (); 
	}
Example #37
0
	void BeingTriggered()
	{
		if (isTriggered) 
		{
			isTriggered = false;
			currentState = AIState.Search;
			triggerCoolDown = maxTriggerCooldown; 
			int[] searchCoords = Utilities.Vector2ToCoords (triggered);
			currentAI = new AISearchArea (currentPlayer, searchCoords); 
			Debug.Log("Is triggered"); 
		}

		if (currentState == AIState.Search) 
		{
			if (triggerCoolDown >= 0) {
				triggerCoolDown -= Time.deltaTime;
			}else if (triggerCoolDown < 0){
				currentState = AIState.Standard;
				currentAI = standardAI; 
			}
		}
	}
Example #38
0
 public void OnBeingScared(AIBase enemy, GameObject scaringObject, int scaringSize)
 {
     // Plays the scared sound
     _audioSource.clip = scaredSound;
     _audioSource.Play();
 }
Example #39
0
 public void OnBeginChase(AIBase enemy, GameObject chasedObject)
 {
     // Plays the chase sound
     _audioSource.clip = chaseSound;
     _audioSource.Play();
 }
 public void OnBeingScared(AIBase enemy, GameObject scaringObject, int scaringSize)
 {
     foreach (EnemyBehaviourListener listener in GetComponentsInChildren<EnemyBehaviourListener>())
         if (listener != this)
             listener.OnBeingScared(enemy, scaringObject, scaringSize);
 }
Example #41
0
 public void OnAttack(AIBase enemy, GameObject attackedObject, Vector3 velocity)
 {
     // Plays the hit sound
     if (attackedObject == gameObject)
         hit.PlayAudio();
 }
Example #42
0
    // Use this for initialization
    protected void Start()
    {
        if (emitter != null) {
                emitter.Emit ();//запускаем эмиттер
                isSpawn = true;//отключаем движения и повреждения
        }
        if (!photonView.isMine) {

                        Destroy (GetComponent<ThirdPersonController> ());
                        Destroy (GetComponent<ThirdPersonCamera> ());
                        Destroy (GetComponent<MouseLook> ());
                        GetComponent<Rigidbody> ().isKinematic = true;
        } else {
            cameraController=GetComponent<ThirdPersonCamera> ();
            isAi = cameraController==null;
        }
        mainAi =  GetComponent<AIBase> ();
        isAi = mainAi!=null;

        correctPlayerPos = transform.position;
        myCollider = collider;

        centerOffset = capsule.bounds.center - myTransform.position;
        headOffset = centerOffset;
        headOffset.y = capsule.bounds.max.y - myTransform.position.y;

        distToGround = capsule.height/2-capsule.center.y;
        charMan = GetComponent<CharacteristicManager> ();
        charMan.Init ();
        health= charMan.GetIntChar(CharacteristicList.MAXHEALTH);
        //Debug.Log (distToGround);
    }
Example #43
0
 public void OnEndChase(AIBase enemy, GameObject chasedObject)
 {
 }
Example #44
0
 public void OnAttack(AIBase enemy, GameObject attackedObject, Vector3 velocity)
 {
 }
Example #45
0
	public abstract IEnumerator RunTask(AIBase _ai);
 public void OnAttack(AIBase enemy, GameObject attackedObject, Vector3 velocity)
 {
     // Plays the hit effect
     if (attackedObject == gameObject) {
         Transform characterTransform = attackedObject.transform;
         hit.PlayEffect(characterTransform.position, characterTransform.rotation, _characterSize.GetSize());
     }
 }
Example #47
0
	void CheckForInput()
	{
		if (workingAI != null && (publicInputVector != Vector3.zero || publicInteractVector != Vector3.zero)) 
		{
			workingAI = null; 
		}

		if (CombatMode) {
			bool successfulInteraction = AttackInDirection (publicInteractVector); 
			publicInteractVector = Vector3.zero;
		} else {
			FilterInteractInputs(publicInteractVector); 
			publicInteractVector = Vector3.zero;
		}


		MovePlayer (publicInputVector);
		publicInputVector = Vector3.zero;
	}
Example #48
0
    // Use this for initialization
    protected void Start()
    {
        aSource = GetComponent<AudioSource> ();

        sControl = new soundControl (aSource);//создаем обьект контроллера звука
        _canWallRun = canWallRun;
        //проигрываем звук респавна
        sControl.playClip (spawnSound);

        if (emitter != null) {
                emitter.Emit ();//запускаем эмиттер
                isSpawn = true;//отключаем движения и повреждения
        }

        if (!photonView.isMine) {

                        Destroy (GetComponent<ThirdPersonController> ());
                        Destroy (GetComponent<ThirdPersonCamera> ());
                        Destroy (GetComponent<MouseLook> ());
                        GetComponent<Rigidbody> ().isKinematic = true;
                        //ivnMan.Init ();
        } else {
            cameraController=GetComponent<ThirdPersonCamera> ();
            isAi = cameraController==null;
        }
        mainAi =  GetComponent<AIBase> ();
        isAi = mainAi!=null;

        correctPlayerPos = transform.position;
        myCollider = collider;
        ivnMan.Init ();
        centerOffset = capsule.bounds.center - myTransform.position;
        headOffset = centerOffset;
        headOffset.y = capsule.bounds.max.y - myTransform.position.y;

        distToGround = capsule.height/2-capsule.center.y;
        charMan = GetComponent<CharacteristicManager> ();
        charMan.Init ();
        health= charMan.GetIntChar(CharacteristicList.MAXHEALTH);
        if (canJump) {
            jetPackCharge = charMan.GetIntChar(CharacteristicList.JETPACKCHARGE);
        }
        ivnMan.Init ();
        AfterSpawnAction ();
        //Debug.Log (distToGround);
    }
 public void OnEndChase(AIBase enemy, GameObject chasedObject)
 {
     foreach (EnemyBehaviourListener listener in GetComponentsInChildren<EnemyBehaviourListener>())
         if (listener != this)
             listener.OnEndChase(enemy, chasedObject);
 }
Example #50
0
	public sealed override IEnumerator RunTask(AIBase _ai)
	{
		yield return RunTask(_ai as AIHuman);
	}
Example #51
0
 public void OnBeginChase(AIBase enemy, GameObject chasedObject)
 {
     // Sets the eyes' color to the chase one
     _targetEyeColor = eyesChaseColor;
 }
Example #52
0
		public void SwitchState (AIBase newState)
		{
				currentState.enabled = false;
				currentState = newState;
				currentState.enabled = true;
		}
Example #53
0
 public void OnBeginChase(AIBase enemy, GameObject chasedObject)
 {
 }
Example #54
0
 public void OnBeingScared(AIBase enemy, GameObject scaringObject, int scaringSize)
 {
     // Disables the help item
     enabled = false;
     Hide();
 }
 public void OnAttack(AIBase enemy, GameObject attackedObject, Vector3 velocity)
 {
     // Sets the hit flag
     _animator.SetBool(CharacterAnimatorParameters.Hit, true);
 }
Example #56
0
	public void UpdateGameState()
	{
		if (CurrentState == GameState.LevelWin || CurrentState == GameState.LevelLost)
		{
			// Clear Game
			if (GameManager.CurrentLevel != null)
			{
				GameManager.CurrentLevel.ClearAndDestroy();
				GameManager.CurrentLevel = null;
			}
		}
		
		if (CurrentState == GameState.GameStart)
		{
			ShowUIMenu(TitleMenu);
			OnClickGotoState = GameState.Intro;
			
			// Reset game
			CurrentLevelIndex = 0;
			RetriesUsed = 0;
		}
		else if(CurrentState == GameState.Intro)
		{	
			ShowUIMenu(InfoMenu);
			OnClickGotoState = GameState.LoadLevel;
		}
		else if(CurrentState == GameState.LoadLevel)
		{
			LevelComboWins = 0;
			LevelCombosPlayed = 0;
			
			if(LoadCurrentLevel())
			{
				ShowUIMenu(null);
				ChangeState(GameState.GameAI);
			}
		}
		else if(CurrentState == GameState.GameAI)
		{
			if (GameManager.CurrentLevel != null)
			{
				ShowUIMenu(ReadyMenu);
				
				PointRaytrace.CurrentPlayerHitsID = "";
				
				// Create AI if null
				if (CurrentAI == null)
				{
					CurrentAI = AIBase.CreateAIToGameobject(GameManager.CurrentLevel.gameObject);
				}
				
				GameManager.CurrentLevel.DeactivateAll();
				
				// Showing to player what to do
				CurrentAI.StartShowHint();
			}
			else
			{
				Debug.LogError("Cant Play NULL Level!");
			}			
		}
		else if(CurrentState == GameState.GamePlayer)
		{
			ShowUIMenu(StartMenu);
			Invoke("HideUIMenus", 1f);
			
			LevelCombosPlayed++;
			
			// Players turn
			CurrentAI.Stop();
		}
		else if (CurrentState == GameState.LevelWinOutro)
		{
			ShowUIMenu(SuccessMenu);
			Invoke("LevelWinOutroComplete", 2f);
		}
		else if (CurrentState == GameState.LevelWin)
		{
			ShowUIMenu(WinMenu);
			OnClickGotoState = GameState.LoadLevel;
			CurrentLevelIndex++;
		}
		else if (CurrentState == GameState.LevelLost)
		{	
			RetriesUsed++;
			if (AcceptedRetries >= RetriesUsed)
			{
				ShowUIMenu(LostMenu);
				Debug.Log(RetriesUsed + " of " + AcceptedRetries + " AcceptedRetries");
				OnClickGotoState = GameState.LoadLevel;
				
				BlockClickFor(0.5f);
			}
			else
			{
				ShowUIMenu(GameLoseMenu);
				OnClickGotoState = GameState.GameStart;
				
				BlockClickFor(0.5f);
			}
		}
		else if (CurrentState == GameState.GameEndWin)
		{
			ShowUIMenu(GameOverMenu);
			Invoke("ReplayFromStart", 10f);
		}
	}
Example #57
0
 public void OnBeingScared(AIBase enemy, GameObject scaringObject, int scaringSize)
 {
     // Do nothing
 }
Example #58
0
 public void OnEndChase(AIBase enemy, GameObject chasedObject)
 {
     // Returns the eyes' color to the idle one
     _targetEyeColor = eyesIdleColor;
 }
Example #59
0
 public void OnBeginChase(AIBase enemy, GameObject chasedObject)
 {
     // Do nothing
 }
 public void OnAttack(AIBase enemy, GameObject attackedObject, Vector3 velocity)
 {
     foreach (EnemyBehaviourListener listener in GetComponentsInChildren<EnemyBehaviourListener>())
         if (listener != this)
             listener.OnAttack(enemy, attackedObject, velocity);
 }