Пример #1
0
    private void Awake()
    {
        receiver = GetComponent<ControllerWheels>();
        sphereCollider = this.GetComponent<SphereCollider>();
        //Debug.LogWarning("HARDCODED");
        sphereCollider.isTrigger = true;
        sphereCollider.radius = 20f;

        receiverColliders = GetComponents<Collider>().ToList();
        receiverColliders = GetComponentsInChildren<Collider>().ToList();
        receiverColliders.ForEach(hC => Physics.IgnoreCollision(sphereCollider, hC));

        m_hRigidbody = this.GetComponent<Rigidbody>();

        //FSM
        idle = new StateIdle(this);
        patrol = new StatePatrol(this);
        onAir = new StateOnAir(this);
        wait = new StateWait(this);

        patrol.Idle = idle;
        patrol.OnAir = onAir;
        onAir.Wait = wait;
        wait.Patrol = patrol;

        currentState = idle;
        currentState.OnStateEnter();
    }
Пример #2
0
    public void Awake()
    {
        if (!Mathf.Approximately(Spawns.Sum(hS => hS.Chance), 1f))
            throw new UnityException(this.gameObject.name + ": Sum of chances must be == 1");

        animator = GetComponent<Animator>();
        units = new List<GameObject>();

        idle = new StateIdle(this);
        ready = new StateReady(this);
        wait = new StateWait(this);
        spawn = new StateSpawn(this);
        open = new StateOpen(this);
        push = new StatePush(this);
        close = new StateClose(this);

        ready.Wait = wait;
        wait.Spawn = spawn;
        spawn.Open = open;
        open.Push = push;
        push.Close = close;
        close.Ready = ready;

        currentState = ready;
        ready.OnStateEnter();
    }
    // Use this for initialization
    public override void Start()
    {
        base.Start();
        WalkingState = new StateWalk(this, enemy, initialDirection, true, true, true, Speed);
        TurningState = new StateWait(this, enemy, TurnDuration);

        ActiveState   = WalkingState;
        FaceDirection = WalkingState.direction;
    }
Пример #4
0
    // Use this for initialization
    public override void Start()
    {
        base.Start();
        enemy.animator.SetBool("FaceRight", (initialDirection == Direction.Right) ? true : false);
        enemy.animator.SetBool("EyeClosed", true);

        WaitEyeClosed = new StateWait(this, enemy, GetRandomClosedWaitTime());
        WaitEyeOpen   = new StateWaitDamage(this, enemy, maxOpenWaitTime);
        ActiveState   = WaitEyeClosed;
    }
    // 各ステート実体化
    void EachStateOfInstance()
    {
        var canvas = GameObject.FindObjectOfType <Canvas> ();
        var prefab = Resources.Load <GameObject> ("Prefab/RoomScene/Room_Select");

        m_selectState = GameObject.Instantiate(prefab, canvas.transform).GetComponent <StateSelect> ();
        m_selectState.gameObject.SetActive(true);

        prefab        = Resources.Load <GameObject> ("Prefab/RoomScene/Room_NameSet");
        m_createState = GameObject.Instantiate(prefab, canvas.transform).GetComponent <StateCreateRoom> ();
        m_createState.gameObject.SetActive(false);

        prefab      = Resources.Load <GameObject> ("Prefab/RoomScene/Room_NameEnter");
        m_joinState = GameObject.Instantiate(prefab, canvas.transform).GetComponent <StateJoinRoom> ();
        m_joinState.gameObject.SetActive(false);

        prefab      = Resources.Load <GameObject> ("Prefab/RoomScene/Room_Wait");
        m_waitState = GameObject.Instantiate(prefab, canvas.transform).GetComponent <StateWait> ();
        m_waitState.gameObject.SetActive(false);
    }
Пример #6
0
        public Bomb() : base("Bomb")
        {
            this.Layer = (uint)CollisionLayer.Bombs;

            collider = new BoxCollider2D(Vector2.One);
            //collider.CollisionMode = CollisionMode.Collision;
            //collider.CollisionEnter += OnCollisionEnter;
            collider.CollisionMode = CollisionMode.Trigger;
            collider.TriggerExit  += OnTriggerExit;
            colliders = new List <BoxCollider2D>();
            AddComponent(collider);
            AddComponent(new BoxCollider2DRenderer(Vector4.Zero));



            locations = new List <Vector2>();
            renderer  = new AnimationRenderer(FlyWeight.Get("Bomb"), 50, 50, 3, new int[] { 0, 1, 2, 1 }, 0.2f, true, false);
            AddComponent(renderer);

            #region FSM
            wait    = new StateWait(this);
            explode = new StateExplode(this);

            explode.Next = wait;
            wait.Next    = explode;

            wait.OnStateEnter();
            AddComponent(new FSMUpdater(wait));

            #endregion

            for (int i = 0; i < bigExplosion; i++)
            {
                Explosion toAdd = Pool <Explosion> .GetInstance(x => x.Active = false);

                explosionList.Add(toAdd);
            }
            // ChooseBomb();
        }