Esempio n. 1
0
    public void spawnWave(SpawnDataOrder data)
    {
        if (!this.isActiveAndEnabled)
        {
            return;
        }
        for (int i = 0; i < data.number; i++)
        {
            var spawnPosition = new Vector3(
                Random.Range(-randomRange, randomRange),
                Random.Range(-randomRange, randomRange),
                0.0f);

            GameObject    grunt    = (GameObject)Instantiate(data.unitPrefab, this.transform.position + spawnPosition, Quaternion.identity);
            CombatHandler gruntObj = grunt.GetComponent <CombatHandler>();
            gruntObj.team = this.team;
            grunt.name    = "Grunt " + this.team;



            WaypointMover gruntWaypoint = grunt.GetComponent <WaypointMover>();
            gruntWaypoint.path   = path;
            gruntWaypoint.offset = spawnPosition;
            //
            NetworkServer.Spawn(grunt);
        }
    }
Esempio n. 2
0
    //private Vector3 leavePosition;

    // Use this for initialization
    void Start()
    {
        inactivePS.Play(true);
        waypointMover               = this.GetComponentInChildren <WaypointMover>();
        patrolWayPoints             = wayPointsHolder.waypoints;
        waypointMover.movementSpeed = patrolMovenmentSpeed;
    }
Esempio n. 3
0
    public UnitRotationController Init(WaypointMover move, Func <Vector3> getRotationTarget)
    {
        handlers  = new List <EventHandler>();
        m_rotated = move.transform;
        //   MDebug.Log(" target");
        move.OnMoveToWayPoint += wp =>
        {
            //     MDebug.Log(" Start");
            StopAllCoroutines();
            handlers.ForEach(h => h());
            handlers = new List <EventHandler>();
            StartCoroutine(TurnToWaypoint(wp));
        };

        move.OnMovementEnd += wp =>
        {
            //    MDebug.Log("  stop");
            StopAllCoroutines();
            handlers.ForEach(h => h());
            handlers = new List <EventHandler>();
            StartCoroutine(TurnToFinalPosition(getRotationTarget()));
        };

        StartCoroutine(TurnToFinalPosition(getRotationTarget()));
        return(this);
    }
Esempio n. 4
0
    public void SetMovementTile(Tile target, List <Tile> path)
    {
        Owner.SetTile(target, false);

        WaypointMover mover = Owner.GetComponent <WaypointMover>();

        mover.MoveOnPath(path, 3);

        mover.OnMovementEnd += OnMoveEnd;
    }
Esempio n. 5
0
    void Count()
    {
        count++;
        if (count == 10)
        {
            TrackingManager.TrackingCall_EasterEgg("10", PlayerLevel.Instance.GetCurrentLevel());
            WaypointMover          mover = gameObject.AddComponent <WaypointMover>();
            UnitRotationController contr = gameObject.AddComponent <UnitRotationController>().Init(mover, _foo);
            contr.TurnToPosition(Camera.main.transform, () => m_animation.SetTrigger(UnitAnimationTypes.bAggro.ToString()));
        }
        else if (count == 20)
        {
            TrackingManager.TrackingCall_EasterEgg("20", PlayerLevel.Instance.GetCurrentLevel());
            m_animation.SetTrigger(UnitAnimationTypes.bDying.ToString());
        }
        else if (count == 3 || (count > 3 && M_Math.Roll(0.1f)))
        {
            TrackingManager.TrackingCall_EasterEgg("3", PlayerLevel.Instance.GetCurrentLevel());

            m_animation.SetTrigger(UnitAnimationTypes.bHit.ToString());
        }
    }
Esempio n. 6
0
    //----------------------------------------------------------------------------------
    void Start()
    {
        if (!waypointMover)
        {
            waypointMover = GetComponent <WaypointMover>();
        }

        animationComponent = GetComponent <Animation>();

        if (!idleAnimation && idleVariations.Length > 0)
        {
            idleAnimation = idleVariations[0];
        }
        if (!moveAnimation && moveVariations.Length > 0)
        {
            moveAnimation = moveVariations[0];
        }
        if (!jumpAnimation && jumpVariations.Length > 0)
        {
            jumpAnimation = jumpVariations[0];
        }
    }
Esempio n. 7
0
    void Awake()
    {
        EnemyCount++;
        hitCount     = 0;
        sprite       = GetComponent <Renderer>();
        wander       = GetComponent <Wander>();
        waypoint     = GetComponent <WaypointMover>();
        stunnedState = GetComponent <StunnedState>();
        eggState     = GetComponent <EggState>();
        ccwState     = GetComponent <CCWState>();
        cwState      = GetComponent <CWState>();
        chaseState   = GetComponent <ChaseState>();
        enlargeState = GetComponent <EnlargeState>();
        shrinkState  = GetComponent <ShrinkState>();

        gameObject.GetComponent <Animator>().Play("Idle");
        if (waypoint == null)
        {
            waypoint = gameObject.AddComponent <WaypointMover>();
        }

        enemies.Add(this);
    }
 void Awake()
 {
     _mover            = GetComponent <WaypointMover>();
     _squad            = GameObject.FindObjectOfType <ZombieSquad>();
     _initialMoveSpeed = _mover.MoveSpeed;
 }