Пример #1
0
    protected void FormPattern(LanePattern pattern, int lane, LaneManager[] Board)
    {
        LaneManager TheLane = Board[lane - 1];

        CreatureBase[] FriendlyCreatures = TheLane.GetFriendliesInLane(this).ToArray();
        if (FriendlyCreatures.Length == 0)
        {
            foreach (Spawnable spawntype in pattern.PatternDefinition)
            {
                AIResponse.Spawn(spawntype, lane);
            }
            return;
        }
        LanePattern lanePattern = new LanePattern(FriendlyCreatures);

        if (LanePattern.Equals(lanePattern))
        {
            return;
        }

        for (int i = 0; i < LanePattern.PatternDefinition.Length; i++)
        {
            if (lanePattern.PatternDefinition.Length <= i || LanePattern.PatternDefinition[i] != lanePattern.PatternDefinition[i])
            {
                if (!AIResponse.Spawn(LanePattern.PatternDefinition[i], lane))
                {
                    Debug.Log("~~~~ Failed Spawn in Pattern");
                }
                else
                {
                    Debug.Log("~~~~ Success Spawn in Pattern");
                }
            }
        }
    }
Пример #2
0
    private void Awake()
    {
        trackObjectManager = GetComponent <TrackObjectManager>();
        laneManager        = GetComponent <LaneManager>();

        nextTrackSectionPosition = startSectionLength;
    }
Пример #3
0
    void Awake()
    {
        animator    = GetComponent <Animator>();
        laneManager = GameObject.Find("Lanes").GetComponent <LaneManager>();

        GameManager.StartGame += Run;
        GameManager.EndGame   += isHit;
    }
Пример #4
0
    private void Awake()
    {
        gameController     = GetComponent <GameController>();
        laneManager        = GetComponent <LaneManager>();
        trackObjectManager = GetComponent <TrackObjectManager>();

        playerObject = Instantiate(playerPrefab);
        playerObject.GetComponent <PlayerCollisions>().playerController = this;
    }
Пример #5
0
 private void UpdateLaneAdvantage()
 {
     for (int i = 0; i < 3; i++)
     {
         LaneManager activeLane = TournamentManager._instance.lanes[i];
         LI_LaneAdvantage[i] = activeLane.GetFriendliesInLane(this).Count - activeLane.GetEnemiesInLane(this).Count;
         iFriendlyCount     += TournamentManager._instance.lanes[i].GetFriendliesInLane(this).Count;
         //LogStack.Log("LaneAdvantage[" + i + "] = " + LI_LaneAdvantage[i].ToString(), LogLevel.Debug);
     }
 }
    // 0 always top lane
    // 1 always bottom lane
    public void assignToLane(int laneID)
    {
        if (laneID != laneIndex || !initLaneSet)
        {
            laneIndex = laneID;

            GameManager gm = GameManager.getGM();

            myLane    = gm.getTeamLanes(myFlow.team)[laneID];
            enemyLane = gm.getTeamLanes(myFlow.getEnemyTeam())[laneID];

            enemyGroundUnitsContainer = enemyLane.frontWave;
        }

        //GameManager.getGM()
    }
Пример #7
0
 void Awake()
 {
     if (instance == null || instance.Equals(null))
     {
         instance      = this;
         lanePositions = new float[transform.childCount];
         for (int i = 0; i < transform.childCount; ++i)
         {
             lanePositions[i] = transform.GetChild(i).GetComponent <RectTransform>().position.x;
         }
     }
     else
     {
         Destroy(this);
     }
 }
    public override void OnInspectorGUI()
    {
        // Draw the normal inspector elements first.
        DrawDefaultInspector();

        // Get a reference to the script this class is an editor of.
        LaneManager script = (LaneManager)target;

        // Show a button to regenerate the lanes.
        if (GUILayout.Button("Regenerate lanes"))
        {
            if (Application.isPlaying)
            {
                script.RegenerateLanes();
            }
        }
    }
Пример #9
0
 public void Init(LogicBase _owner, LaneManager _lane, Spawnable _type, UIHealth _healthUI, float _damageAmount)
 {
     if (init == false)
     {
         owner          = _owner;
         lane           = _lane;
         creatureType   = _type;
         uiHealth       = _healthUI;
         damageAmount   = _damageAmount;
         range          = _type == Spawnable.Bunny ? TournamentManager._instance.bunnyRange : TournamentManager._instance.unicornRange;
         init           = true;
         activeLaneNode = lane.GetFirstLaneNode(owner);
         activeLaneNode.activeCreature = this;
         owner._Creatures.Add(this);
         rightFacing = owner._RightFacing;
         // Debug.Log ("Creature owned by " + owner);
     }
 }
    public void rpcInit(int parentLaneID, Vector3 offset, float range, int teamNum)
    {
        //Debug.LogError(" CREEP INIT RPC CALLED");

        parentLane     = PhotonNetwork.GetPhotonView(parentLaneID).GetComponent <LaneManager>();
        this.myOffset  = offset;
        effectiveRange = range;
        myFlow.team    = CombatFlow.convertNumToTeam((short)teamNum);
        //parentLane.waypoints.CopyTo(waypoints);
        parentLane.myLaneUnits.Add(myFlow);

        if (turret != null)
        {
            turret.setShellTeam(myFlow.team);
        }


        // copy list from parent
        waypoints = new List <Vector3>(parentLane.waypoints);

        lookAtWaypoint();

        //transform.rotation = Quaternion.LookRotation(waypoints[0].position - transform.position, Vector3.up);
    }
Пример #11
0
 void Awake()
 {
     Instance = this;
 }
Пример #12
0
 private void Awake()
 {
     laneManager = GetComponent <LaneManager>();
 }
Пример #13
0
 void Awake()
 {
     instance = this;
 }
Пример #14
0
 private void Awake()
 {
     _songScanner     = new SongScanner(_song);
     _noteViewFactory = new NoteViewFactory(_noteViewPrefab);
     _laneManager     = new LaneManager(_lanes);
 }
 private void Start()
 {
     Conductor.OnBeat += _OnBeat;
     laneManager       = LaneManager.instance;
     animator          = gameObject.GetComponent <Animator>();
 }
Пример #16
0
    //Do spawn is zero indexed but uses spawing like it needsit
    public void DoSpawn(int lane = 0, bool randomlane = false)
    {
        var         enemiesinlane    = 0;
        var         friendliesinlane = 0;
        int         cnt           = 0;
        LaneManager mostImportant = null;

        foreach (LaneManager l in TournamentManager._instance.lanes)
        {
            enemiesinlane    = l.GetEnemiesInLane(this).Count;
            friendliesinlane = l.GetFriendliesInLane(this).Count;

            if (mostImportant == null)
            {
                mostImportant = l;
            }
            else
            {
                if (enemiesinlane > 0 && friendliesinlane == 0)
                {
                    mostImportant = l;
                }
                else
                if (enemiesinlane == 0 && friendliesinlane > 0)
                {
                    if (!(mostImportant.GetEnemiesInLane(this).Count == 0 && mostImportant.GetFriendliesInLane(this).Count == 0) && !(mostImportant.GetEnemiesInLane(this).Count > 0 && mostImportant.GetFriendliesInLane(this).Count == 0))
                    {
                        mostImportant = l;
                    }
                }
                else
                if (enemiesinlane == 0 && friendliesinlane == 0)
                {
                    mostImportant = l;
                }
                else
                {
                    if (!(mostImportant.GetEnemiesInLane(this).Count == 0 && mostImportant.GetFriendliesInLane(this).Count == 0) && !(mostImportant.GetEnemiesInLane(this).Count > 0 && mostImportant.GetFriendliesInLane(this).Count == 0) && !(mostImportant.GetEnemiesInLane(this).Count == 0 && mostImportant.GetFriendliesInLane(this).Count > 0))
                    {
                        mostImportant = l;
                    }
                }
            }
            cnt++;
        }

        Debug.Log("Most important lane is: " + mostImportant.LaneNumber);

        if (mostImportant != null)
        {
            enemiesinlane    = mostImportant.GetEnemiesInLane(this).Count;
            friendliesinlane = mostImportant.GetFriendliesInLane(this).Count;
            cnt = mostImportant.LaneNumber - 1;

            if (enemiesinlane == 0 && friendliesinlane == 0)
            {
                if (Random.Range(0, 3) >= 1)
                {
                    AIResponse.Spawn(Spawnable.Unicorn, cnt + 1);
                }
                else
                {
                    AIResponse.Spawn(Spawnable.Bunny, cnt + 1);
                }
            }
            else
            if (friendliesinlane == 0)
            {
                if (Random.Range(0, 3) >= 1)
                {
                    AIResponse.Spawn(Spawnable.Unicorn, cnt + 1);
                }
                else
                {
                    AIResponse.Spawn(Spawnable.Bunny, cnt + 1);
                }
            }
            else
            {
                CreatureBase highestprog = null;
                foreach (CreatureBase creat in mostImportant.GetFriendliesInLane(this))
                {
                    if (highestprog == null)
                    {
                        highestprog = creat;
                    }
                    else
                    if (creat.LaneProgress > highestprog.LaneProgress)
                    {
                        highestprog = creat;
                    }
                }

                if (highestprog != null)
                {
                    MoveAtk(highestprog);
                }
            }
        }
    }
Пример #17
0
    public override void OnTick(IBoardState[] data)
    {
        if (_Start)
        {
            _Start         = false;
            attackingPairs = new List <AttackingPair> ();
            //---Add empty pairs at start---
            for (int i = 1; i < 4; i++)
            {
                attackingPairs.Add(new AttackingPair(i, this));
            }
        }

        boardState = (LaneManager[])data;

        //---spawn for each pair---
        foreach (var pair in attackingPairs)
        {
            pair.SpawnPair(AIResponse);
        }

        foreach (LaneManager lane in TournamentManager._instance.lanes)
        {
            int playerInLane = lane.GetFriendliesInLane(this).Count;
            if (playerInLane <= 0)
            {
                foreach (var pair in attackingPairs)
                {
                    if (pair.spawnProg == 0)
                    {
                        pair.SpawnPair(AIResponse);
                    }
                }
            }
        }


        #region More than 20
        if (AIResponse.Tokens >= 20)
        {
            LaneManager  _lane           = null;
            CreatureBase _friendlyToMove = null;
            int          previousEnemies = 0;
            bool         _moveAttack     = true;

            //---check each lane---
            foreach (LaneManager lane in TournamentManager._instance.lanes)
            {
                int playerInLane = lane.GetFriendliesInLane(this).Count;
                int enemyInLane  = lane.GetEnemiesInLane(this).Count;
                //---Find Open lane---
                if (enemyInLane == 0 && playerInLane > 0)
                {
                    _lane           = lane;
                    _friendlyToMove = _lane.GetFriendliesInLane(this) [0];
                    //---move the creature to end of lane---
                    int _openNodes = _friendlyToMove.ActiveLaneNode.laneManager.GetOpenNodes(_friendlyToMove.ActiveLaneNode, _RightFacing);
                    //---find pair that contains friendlyToMove---
                    foreach (var pair in attackingPairs)
                    {
                        if (pair.ContainsCreature(_friendlyToMove))
                        {
                            pair.MovePair(AIResponse);
                            break;
                        }
                    }
                    _moveAttack = false;
                    break;
                }
                //---ELSE Find lane with least amount of enemies---
                else if (enemyInLane > 0 && playerInLane > 0)
                {
                    if (enemyInLane > previousEnemies)
                    {
                        previousEnemies = enemyInLane;
                        _lane           = lane;
                        _friendlyToMove = _lane.GetFriendliesInLane(this) [0];
                    }
                }
            }

            Debug.Log("Friendly to move: " + _friendlyToMove);
            Debug.Log("MoveAttack :" + _moveAttack);
            if (_moveAttack && _friendlyToMove != null)
            {
                //---attemp movetowards and attack each enemy in lane, then move to end of lane---
                foreach (CreatureBase _enemy in _lane.GetEnemiesInLane(this))
                {
                    //---Move to enemy, attack, then move to end of Lane---
                    int _openNodes = _friendlyToMove.ActiveLaneNode.laneManager.GetOpenNodes(_friendlyToMove.ActiveLaneNode, _RightFacing);
                    //---find pair that contains friendlyToMove---
                    foreach (var pair in attackingPairs)
                    {
                        if (pair.ContainsCreature(_friendlyToMove))
                        {
                            if (!pair.MovePair(AIResponse))
                            {
                                AttemptMoveAttack();
                            }
                            break;
                        }
                    }
                }
            }
        }
        #endregion
        else
        {
            //---Get Enemy Count---
            GetCount();

            //---If there are Enemies, find the closest---
            if (enemyCount > 0)
            {
                FindNearest();
                //---if neareast found, move towards and attack---
                if (targetCreature != null)
                {
                    AttemptAttackMoveTarget(targetCreature);
                }
            }
            //--else random move or attack--
            else
            {
                AttemptMoveAttack();
            }
        }
        AIResponse.FinalizeResponse();
    }