예제 #1
0
    public virtual void Init(BehaviourController controller)
    {
        m_Controller   = controller;
        m_SceneSetting = controller.creationController.creationData.m_IsoData.m_HeadInfo.FindSceneSetting();

        m_DamageParticlePlayers  = new List <VCParticlePlayer>();
        m_ExplodeParticlePlayers = new List <VCParticlePlayer>();

        VCParticlePlayer[] pps = GetComponentsInChildren <VCParticlePlayer>(false);

        foreach (VCParticlePlayer pp in pps)
        {
            if (pp.FunctionTag == VCParticlePlayer.ftDamaged)
            {
                m_DamageParticlePlayers.Add(pp);
            }
            else if (pp.FunctionTag == VCParticlePlayer.ftExplode)
            {
                m_ExplodeParticlePlayers.Add(pp);
            }
        }

        m_DestructTick = 120.0f;
        m_IsWreckage   = false;
        m_Sinked       = false;
    }
예제 #2
0
    public override BTNodeState Evaluate(BehaviourController controller)
    {
        if (controller.numLabourers > 1)
        {
            return(BTNodeState.SUCCESS);
        }

        Collider[] colliders = Physics.OverlapSphere(controller.town_AIPrefab.transform.position, controller.instancingRadius);
        foreach (Collider collider in colliders)
        {
            Transform  selectedTile = collider.transform;
            Resources  resources    = selectedTile.GetComponent <Resources>();
            SquareUnit squareUnit   = selectedTile.GetComponent <SquareUnit>();
            if (squareUnit != null && resources.building == Resources.Building.Empty && !squareUnit.unit)
            {
                GameObject unitInstantiated = Instantiate(controller.labourer_AIPrefab, selectedTile.position + Vector3.up / 2f, controller.labourer_AIPrefab.transform.rotation);
                unitInstantiated.transform.parent             = selectedTile.transform;
                selectedTile.GetComponent <SquareUnit>().unit = true;
                controller.numLabourers++;
                controller.labourers.Add(unitInstantiated.GetComponent <Unit>());
                break;
            }
        }

        return(BTNodeState.FAILURE);
    }
예제 #3
0
 protected virtual void Awake()
 {
     Motor        = GetComponent <EnemyMovementMotor>();
     Animator     = GetComponent <EnemyAnimatorController>();
     AiController = GetComponentInChildren <BehaviourController>();
     SoundBank    = GetComponentInChildren <EnemySoundBank>();
 }
예제 #4
0
파일: combatStats.cs 프로젝트: jfez/IAp2
    IEnumerator cityCheck(GameObject ciudad)
    {
        yield return(StartCoroutine(checkDistance(ciudad)));

        ciudad.GetComponent <vidaCuidad>().vida -= poder;

        if (ciudad.GetComponent <vidaCuidad>().vida <= 0)
        {
            ciudad.SetActive(false);
        }

        if (gameObject.layer == 14)
        {
            BehaviourController bc = GameObject.FindGameObjectWithTag("TurnManager").GetComponent <BehaviourController>();
            if (gameObject.CompareTag("AI_Troop"))
            {
                bc.numTroops--;
                bc.troops.Remove(gameObject.GetComponent <Unit>());
            }
            else if (gameObject.CompareTag("AI_Explorer"))
            {
                bc.numExplorers--;
                bc.explorers.Remove(gameObject.GetComponent <Unit>());
            }
            else
            {
                bc.numLabourers--;
                bc.labourers.Remove(gameObject.GetComponent <Unit>());
            }
        }
        this.gameObject.GetComponent <SimplePropagator>().removePropagator();
        this.gameObject.SetActive(false);
    }
예제 #5
0
    public override BTNodeState Evaluate(BehaviourController controller)
    {
        if (controller.hasTown)
        {
            return(BTNodeState.SUCCESS);
        }

        Collider[] colliders = Physics.OverlapSphere(controller.mainCiyt_AI.transform.position, controller.buildingRadius);
        foreach (Collider collider in colliders)
        {
            Resources resources = collider.GetComponent <Resources>();
            if (resources != null && resources.building == Resources.Building.Empty)
            {
                Transform selectedTile = collider.transform;
                Instantiate(controller.town_AIPrefab, selectedTile.position + Vector3.up / 2f, controller.town_AIPrefab.transform.rotation);
                selectedTile.GetComponent <Resources>().building = Resources.Building.Town;
                selectedTile.GetChild(0).gameObject.SetActive(false);
                selectedTile.GetChild(1).gameObject.SetActive(false);
                selectedTile.GetChild(2).gameObject.SetActive(false);
                selectedTile.GetChild(3).gameObject.SetActive(false);

                controller.hasTown = true;
                break;
            }
        }

        return(BTNodeState.FAILURE);
    }
예제 #6
0
파일: BTSequencer.cs 프로젝트: jfez/IAp2
    public override BTNodeState Evaluate(BehaviourController controller)
    {
        bool nodeRunning = false;

        foreach (BTNode node in nodes)
        {
            BTNodeState currentNodeState = node.Evaluate(controller);
            switch (currentNodeState)
            {
            case BTNodeState.SUCCESS:
                continue;

            case BTNodeState.RUNNING:
                nodeRunning = true;
                continue;

            case BTNodeState.FAILURE:
                return(currentNodeState);

            default:
                break;
            }
        }

        return(nodeRunning? BTNodeState.RUNNING : BTNodeState.SUCCESS);
    }
예제 #7
0
 public void Awake()
 {
     behaviourController = GetComponent <BehaviourController>();
     animationManager    = GetComponent <AnimationManager>();
     obj_sprite          = transform.Find("Sprite").gameObject;
     spriteRenderer      = obj_sprite.GetComponent <SpriteRenderer>();
 }
예제 #8
0
 public void AddEntity(AbstractEntity beh)
 {
     beh.Belongs = this;
     beh.Initialize();
     lock (EntitiesInTheWorld)
         EntitiesInTheWorld.Add(beh);
     BehaviourController.StartUpdateBehaviour(beh);
 }
예제 #9
0
 public void AddBehaviour(AbstractBehaviour beh)
 {
     beh.Belongs = this;
     beh.Initialize();
     lock (SomethingInTheWorld)
         SomethingInTheWorld.Add(beh);
     BehaviourController.StartUpdateBehaviour(beh);
 }
 private void Awake()
 {
     this.behaviourController = GetComponent <BehaviourController>();
     speedFloat = Animator.StringToHash(FC.AnimatorKey.Speed);
     canSprint  = true;
     // 동작 타입을 해시코드로 가지고있다가 추후 구별용으로 사용
     behaviourCode = this.GetType().GetHashCode();
 }
 void Start()
 {
     controller = gameObject.GetComponent<BehaviourController>();
     controller.setBehaviour<Control>();
     controller.target = null;
     fire = gameObject.GetComponent<Fire>();
     fire.aimOffset = Vector3.forward;
 }
예제 #12
0
 public void AddObject(AbstractObject beh)
 {
     beh.Belongs = this;
     beh.Initialize();
     lock (ObjectsInTheWorld)
         ObjectsInTheWorld.Add(beh);
     BehaviourController.StartUpdateBehaviour(beh);
 }
예제 #13
0
파일: BTRandomizer.cs 프로젝트: jfez/IAp2
 public override BTNodeState Evaluate(BehaviourController controller)
 {
     if (Random.value >= 0.5f)
     {
         return(BTNodeState.SUCCESS);
     }
     return(BTNodeState.FAILURE);
 }
예제 #14
0
    public void SetWweaponGroupTogglesVisible(bool visible, BehaviourController controller)
    {
        attackModeAnim.speed = visible ? 1f : -1f;

        for (int i = 0; i < weaponTogglesOn.Length; i++)
        {
            SetWweaponGroupToggles(i, controller.IsWeaponGroupEnabled(i));
        }
    }
예제 #15
0
 public override void Awake()
 {
     base.Awake();
     _anim   = GetComponentInChildren <Animator>();
     _rigid  = GetComponent <Rigidbody2D>();
     _bh     = GetComponent <BehaviourController>();
     _sensor = GetComponentInChildren <EnemySensor>();
     _stat   = GetComponent <GeneralStatistics>();
 }
예제 #16
0
    void Awake()
    {
        _transform             = transform;
        _aiController          = transform.parent.GetComponentInChildren <BehaviourController>();
        _collider              = collider as SphereCollider;
        _originalSightAngle    = SightAngle;
        _originalSightDistance = SightDistance;

        gameObject.layer = LayerMaskStorage.PlayerOnlyLayer;
    }
예제 #17
0
 void Start()
 {
     //Start the coroutine we define below named ExampleCoroutine.
     //StartCoroutine(ExampleCoroutine());
     playerTurn          = true;
     gameGrid            = GameObject.FindGameObjectWithTag("GridManager").GetComponent <TileMouseOver>();
     playerResources     = GetComponent <PlayerResources>();
     behaviourController = GetComponent <BehaviourController>();
     ticTac.SetActive(false);
 }
    protected virtual void Awake()
    {
        DefaultFrequency = Frequency;

        Motor       = transform.parent.GetComponent <EnemyMovementMotor>();
        PathFinder  = transform.parent.GetComponentInChildren <PathFinder>();
        LineOfSight = transform.parent.GetComponentInChildren <LineOfSight>();

        AiController = GetComponent <BehaviourController>();
    }
예제 #19
0
    public override void EnterBehaviour()
    {
        base.EnterBehaviour();
        BehaviourController bc = GetComponent <BehaviourController>();

        if (bc)
        {
            bc.ChangeState(AIState.Agessive);
        }
    }
예제 #20
0
파일: combatStats.cs 프로젝트: jfez/IAp2
    IEnumerator combatCheck(GameObject enemy, float numeroRandom, float porcentajeAtacante)
    {
        yield return(StartCoroutine(checkDistance(enemy)));

        if (numeroRandom <= porcentajeAtacante)
        {
            if (enemy.layer == 14)
            {
                BehaviourController bc = GameObject.FindGameObjectWithTag("TurnManager").GetComponent <BehaviourController>();
                if (enemy.CompareTag("AI_Troop"))
                {
                    bc.numTroops--;
                    bc.troops.Remove(enemy.GetComponent <Unit>());
                }
                else if (enemy.CompareTag("AI_Explorer"))
                {
                    bc.numExplorers--;
                    bc.explorers.Remove(enemy.GetComponent <Unit>());
                }
                else
                {
                    bc.numLabourers--;
                    bc.labourers.Remove(enemy.GetComponent <Unit>());
                }
            }
            enemy.GetComponent <SimplePropagator>().removePropagator();
            enemy.SetActive(false);
        }
        else
        {
            if (gameObject.layer == 14)
            {
                BehaviourController bc = GameObject.FindGameObjectWithTag("TurnManager").GetComponent <BehaviourController>();
                if (gameObject.CompareTag("AI_Troop"))
                {
                    bc.numTroops--;
                    bc.troops.Remove(gameObject.GetComponent <Unit>());
                }
                else if (gameObject.CompareTag("AI_Explorer"))
                {
                    bc.numExplorers--;
                    bc.explorers.Remove(gameObject.GetComponent <Unit>());
                }
                else
                {
                    bc.numLabourers--;
                    bc.labourers.Remove(gameObject.GetComponent <Unit>());
                }
            }
            this.gameObject.GetComponent <SimplePropagator>().removePropagator();
            this.gameObject.SetActive(false);
        }
    }
예제 #21
0
 void Start()
 {
     player = GameObject.Find("Player");
     level  = GameObject.Find("Level");
     playerBehaviorController = player.GetComponent <BehaviourController>();
     levelGenerator           = GameObject.Find("Level").GetComponent <LevelGenerator>();
     uiMenu    = GameObject.Find("Menu");
     title     = GameObject.Find("Title").GetComponent <Text> ();
     score     = GameObject.Find("Score").GetComponent <Text> ();
     uiControl = GameObject.Find("Control");
     uiInfo    = GameObject.Find("Info");
     uiManager();
 }
예제 #22
0
    protected override void Awake()
    {
        base.Awake();
        if (PhotonNetwork.isMasterClient)
        {
            if (photonView.instantiationData != null)
            {
                _spawner = GameObject.Find(photonView.instantiationData[0].ToString()).GetComponent <Spawner>();
            }
        }

        _bh = GetComponent <BehaviourController>();
    }
예제 #23
0
    public override BTNodeState Evaluate(BehaviourController controller)
    {
        if (!controller.hasToMoveLabourers)
        {
            return(BTNodeState.SUCCESS);
        }

        float[,] worldInfluences = controller.worldMap.GetWorldInfluences();

        foreach (Unit unit in controller.labourers)
        {
            Debug.Log("Moving labourers...");
            Vector2I gridPos = controller.worldMap.GetGridPosition(unit.transform.position);

            Vector2I[] neighbors = controller.worldMap.GetNeighbors(gridPos.x, gridPos.y);

            float    maxInfluence    = Mathf.Infinity;
            Vector2I maxInfluencePos = gridPos;
            for (int i = 0; i < neighbors.Length; i++)
            {
                if (worldInfluences[neighbors[i].x, neighbors[i].y] < maxInfluence)
                {
                    maxInfluence    = worldInfluences[neighbors[i].x, neighbors[i].y];
                    maxInfluencePos = new Vector2I(neighbors[i].x, neighbors[i].y);
                }
            }

            GameObject newGO  = new GameObject();
            Transform  target = newGO.GetComponent <Transform>();
            target.position = new Vector3(unit.transform.position.x + (maxInfluencePos.x - gridPos.x), 0.5f, unit.transform.position.z + (maxInfluencePos.y - gridPos.y));

            Collider[] cell = Physics.OverlapSphere(target.position, 0.5f, controller.cellLayer);
            foreach (Collider collider in cell)
            {
                if (collider.GetComponent <Resources>() != null && collider.GetComponent <Resources>().building == Resources.Building.Empty && !collider.GetComponent <SquareUnit>().unit)
                {
                    collider.GetComponent <SquareUnit>().unit     = true;
                    unit.GetComponentInParent <SquareUnit>().unit = false;
                    unit.Pathing(unit.transform, target);
                    unit.transform.parent = collider.transform;
                    break;
                }
            }

            Destroy(newGO);
        }

        controller.hasToMoveLabourers = false;

        return(BTNodeState.FAILURE);
    }
예제 #24
0
    public override BTNodeState Evaluate(BehaviourController controller)
    {
        foreach (BTNode node in nodes)
        {
            BTNodeState currentNodeState = node.Evaluate(controller);
            switch (currentNodeState)
            {
            case BTNodeState.SUCCESS:
                return(currentNodeState);

            case BTNodeState.FAILURE:
                continue;

            default:
                break;
            }
        }

        return(BTNodeState.FAILURE);
    }
예제 #25
0
 void Awake()
 {
     spriteRenderer = transform.FindChild("Sprite").GetComponent <SpriteRenderer>();
     controller     = GetComponent <BehaviourController>();
 }
예제 #26
0
 void Awake()
 {
     behaviourController = GetComponent <BehaviourController>();
     col       = transform.GetComponent <BoxCollider2D>();
     spriteObj = transform.Find("Sprite").gameObject;
 }
예제 #27
0
 void Awake()
 {
     gameStateController = GetComponent<BehaviourController>();
     gameStateController.onBehaviourChange += new BehaviourController.BehaviourChangeHandler(OnChangeState);
 }
예제 #28
0
    public override BTNodeState Evaluate(BehaviourController controller)
    {
        if (!controller.hasToMoveTroops)
        {
            return(BTNodeState.SUCCESS);
        }

        int count = 0;

        float[,] worldInfluences = controller.worldMap.GetWorldInfluences();

        foreach (Unit unit in controller.troops)
        {
            Debug.Log("Moving troops...");
            GameObject newGO  = new GameObject();
            Transform  target = newGO.GetComponent <Transform>();

            Collider[] playerCityCollider = Physics.OverlapSphere(unit.transform.position, 1.4f, controller.playerCity);
            if (playerCityCollider.Length != 0)
            {
                target.position = new Vector3(playerCityCollider[0].transform.position.x, 0.5f, playerCityCollider[0].transform.position.z);

                unit.Pathing(unit.transform, target);
                unit.GetComponent <combatStats>().atacarCiudad(playerCityCollider[0].gameObject);
                unit.GetComponentInParent <SquareUnit>().unit = false;
                unit.transform.parent = null;

                Destroy(newGO);
                count++;
                continue;
            }

            Transform  playerCitizenCell = null;
            Collider[] surroundingCells  = Physics.OverlapSphere(unit.transform.position, 1.4f, controller.cellLayer);
            foreach (Collider col in surroundingCells)
            {
                if (col.GetComponentInChildren <Unit>() != null && col.GetComponentInChildren <Unit>().gameObject.CompareTag("Player"))
                {
                    playerCitizenCell = col.transform;
                }
            }

            if (playerCitizenCell != null)
            {
                target.position = new Vector3(playerCitizenCell.position.x, 0.5f, playerCitizenCell.position.z);

                Collider[]      aiCitizens     = Physics.OverlapSphere(target.position, 1.4f, controller.aiCitizen);
                List <Collider> colliderFilter = new List <Collider>();
                foreach (Collider col in aiCitizens)
                {
                    if (!col.isTrigger)
                    {
                        colliderFilter.Add(col);
                    }
                }

                if (colliderFilter.Count == 1 || colliderFilter.Count > 1 && count == 0)
                {
                    Debug.Log("attacking!");
                    unit.GetComponent <combatStats>().puedeMoverse = false;
                    unit.GetComponentInParent <SquareUnit>().unit  = false;
                    unit.Pathing(unit.transform, target);
                    unit.GetComponent <combatStats>().combate(playerCitizenCell.GetComponentInChildren <Unit>().gameObject);
                    unit.transform.parent = playerCitizenCell;

                    Destroy(newGO);
                    count++;
                    continue;
                }
            }

            Vector2I gridPos = controller.worldMap.GetGridPosition(unit.transform.position);

            Vector2I[] neighbors = controller.worldMap.GetNeighbors(gridPos.x, gridPos.y);

            float meanInfluence = 0f;
            for (int i = 0; i < neighbors.Length; i++)
            {
                meanInfluence += worldInfluences[neighbors[i].x, neighbors[i].y];
            }
            meanInfluence /= neighbors.Length;

            float    difference       = Mathf.Infinity;
            Vector2I meanInfluencePos = gridPos;
            for (int i = 0; i < neighbors.Length; i++)
            {
                float currentDifference = Mathf.Abs(worldInfluences[neighbors[i].x, neighbors[i].y] - meanInfluence);
                if (currentDifference < difference)
                {
                    difference       = currentDifference;
                    meanInfluencePos = new Vector2I(neighbors[i].x, neighbors[i].y);
                }
            }

            target.position = new Vector3(unit.transform.position.x + (meanInfluencePos.x - gridPos.x), 0.5f, unit.transform.position.z + (meanInfluencePos.y - gridPos.y));

            Collider[] cell = Physics.OverlapSphere(target.position, 0.5f, controller.cellLayer);
            foreach (Collider collider in cell)
            {
                if (collider.GetComponent <Resources>() != null && collider.GetComponent <Resources>().building == Resources.Building.Empty && !collider.GetComponent <SquareUnit>().unit)
                {
                    collider.GetComponent <SquareUnit>().unit     = true;
                    unit.GetComponentInParent <SquareUnit>().unit = false;
                    unit.Pathing(unit.transform, target);
                    unit.transform.parent = collider.transform;
                    break;
                }
            }

            Destroy(newGO);
            count++;
        }

        controller.hasToMoveTroops = false;

        return(BTNodeState.FAILURE);
    }
예제 #29
0
 void Awake()
 {
     _aiController = transform.parent.GetComponentInChildren <BehaviourController>();
     _pathHistory  = new Path[MaxPathHistoryEntries];
 }
예제 #30
0
    //=============================================
    //
    //   ####  ######    ###    #####    ######
    //  ##       ##     ## ##   ##  ##     ##
    //   ###     ##    ##   ##  #####      ##
    //     ##    ##    #######  ##  ##     ##
    //  ####     ##    ##   ##  ##   ##    ##
    //
    //=============================================

    void Start()
    {
        rb = GetComponent <Rigidbody>();
        behaviourController = GetComponent <BehaviourController>();
        level = GameObject.Find("Level");
    }
 void Start()
 {
     controller = gameObject.GetComponent<BehaviourController>();
     controller.target = target;
 }
예제 #32
0
 private void Awake()
 {
     _bh = GetComponentInParent <BehaviourController>();
 }
예제 #33
0
파일: BTNode.cs 프로젝트: jfez/IAp2
 public abstract BTNodeState Evaluate(BehaviourController controller);