Inheritance: MonoBehaviour
コード例 #1
0
    /// <summary>
    /// コントローラの初期化
    /// </summary>
    private void initGorillaController()
    {
        gameManager          = GameObject.FindObjectOfType <GameManager>();
        playerMoveController = GameObject.Find(PathMaster.DOG_MOVE_CONTROLLER).GetComponent <PlayerMoveController>();
        attackController     = GameObject.Find(PathMaster.ATTACK_CONTROLLER).GetComponent <AttackController>();
        sweetController      = GameObject.Find(PathMaster.SWEET_CONTROLLER).GetComponent <SweetController>();
        sensorController     = GameObject.Find(PathMaster.SENSOR_CONTROLLER).GetComponent <SensorController>();
        skillController      = GameObject.Find(PathMaster.SKILL_CONTROLLER).GetComponent <SkillController>();
        mainCamera           = Camera.main;
        CameraController cameraController = mainCamera.GetComponent <CameraController>();

        cameraController.Player = this.gameObject;
        cameraController.InitCameraController();
        cameraAnimator = mainCamera.GetComponent <Animator>();

        this.FixedUpdateAsObservable()
        .Where(_ => isInBattleState())
        .Subscribe(x => playerBehavior());
        this.FixedUpdateAsObservable()
        .Where(x => attackController.GetAttackable() && isInBattleState())
        .Subscribe(_ => gorillaAttack());
        this.FixedUpdateAsObservable()
        .Where(x => sweetController.GetUsable() && isInBattleState())
        .Subscribe(_ => useSweet());
        this.FixedUpdateAsObservable()
        .Where(x => sensorController.GetUsable() && isInBattleState())
        .Subscribe(_ => useSensor());
        this.FixedUpdateAsObservable()
        .Where(x => skillController.GetSkillUsable() && isInBattleState())
        .Subscribe(_ => useSkill());
    }
コード例 #2
0
 public void Start()
 {
     ic   = GetComponent <InputController>();
     ac   = GetComponent <AttackController>();
     pmc  = GetComponent <PlatformMovementController>();
     rend = GetComponent <SpriteRenderer>();
 }
コード例 #3
0
 private void Start()
 {
     _attackController = GetComponent <AttackController>();
     _activeBars       = new List <HorizontalBar>();
     SetupEventListeners();
     SetupInitialStage();
 }
コード例 #4
0
ファイル: UnitBehaviour.cs プロジェクト: V0000/TowerDefence
 void Start()
 {
     ObjectRegistry.AddUnit(gameObject, isEnemy);
     agent            = GetComponent <NavMeshAgent>();
     attackController = GetComponent <AttackController>();
     FindTargetPerTime();
 }
コード例 #5
0
    public override void Think(Thinker thinker)
    {
        DrakeController    drake     = thinker.Remember <DrakeController>("drake");
        MovementController mc        = thinker.Remember <MovementController>("movement");
        AttackController   at        = thinker.Remember <AttackController>("attack");
        Vector2            moveInput = thinker.Remember <Vector2>("moveInput");

        if (!mc.IsGrounded)
        {
            return;
        }

        if (moveInput.sqrMagnitude <= 0)
        {
            moveInput = new Vector2(1, 0);
        }
        else if (mc.IsAtWall() || mc.IsAtEdge())
        {
            moveInput.x *= -1;
        }

        thinker.Remember("moveInput", moveInput);
        drake.Walk(moveInput);

        if (target.Value != null && at.AttackCollider.bounds.Intersects(target.Value.bounds))
        {
            drake.Attack();
        }
    }
コード例 #6
0
    public virtual void CastLocalAttack(Vector2 startPosition, Vector2 targetPosition)
    {
        AttackController attack = GetAttack();

        attack.Initialize(this, AttackController.MoveType.Target);
        attack.SetMovement(startPosition, targetPosition, attackSpeed);
    }
コード例 #7
0
    public ADController(AttackController attackController, DefenseController defenseController)
    {
        this.state = ADStateAlt.None;

        this.attackController  = attackController;
        this.defenseController = defenseController;
    }
コード例 #8
0
    // Use this for initialization
    void Start()
    {
        if (PlayerNumber < 1 || PlayerNumber > 4)
        {
            Debug.LogError("Don't do that again. -- Victor");
        }

        movementController  = GetComponent <MovementController>();
        jumpThrowController = GetComponent <JumpThrowController>();
        attackController    = GetComponent <AttackController>();
        landingLogic        = GetComponent <LandingLogic>();
        rigid = GetComponent <Rigidbody>();
        floor = GetComponentInChildren <FloorCollider>();

        Transform indicatorTransform = transform.Find("Indicator");

        if (indicatorTransform == null)
        {
            Debug.LogError("Please attach an Indicator to the player (both human and robot)!");
        }
        else
        {
            indicator = indicatorTransform.gameObject;
        }

        startPosition = transform.position;
    }
コード例 #9
0
ファイル: Enemy.cs プロジェクト: bendevorg/into-the-light
    protected override void Start()
    {
        base.Start();
        rend = GetComponent <Renderer>();

        pathfinder       = GetComponent <NavMeshAgent> ();
        attackController = GetComponent <AttackController>();

        if (GameObject.FindGameObjectWithTag("Player") != null)
        {
            currentState = State.Chasing;
            hasTarget    = true;

            target                = GameObject.FindGameObjectWithTag("Player").transform;
            targetEntity          = target.GetComponent <LivingEntity> ();
            targetEntity.OnDeath += OnTargetDeath;

            myCollisionRadius     = GetComponent <CapsuleCollider> ().radius;
            targetCollisionRadius = target.GetComponent <CapsuleCollider> ().radius;

            StartCoroutine(UpdatePath());
            StartCoroutine(Attack());

            spawner = FindObjectOfType <Spawner>();
            GetComponent <LivingEntity>().OnDeath += spawner.OnEnemyDeath;
            GetComponent <LivingEntity>().OnDeath += AddPoints;
        }
    }
コード例 #10
0
    // Update is called once per frame
    void Update()
    {
        rb.velocity = new Vector3(Input.GetAxis("Horizontal") * speed,
                                  rb.velocity.y,
                                  Input.GetAxis("Vertical") * speed);

        rb.rotation = cameraObject.transform.rotation;

        if (Input.GetAxis("Fire1") > 0.0f)
        {
            chargeTime += Time.deltaTime;
            if (chargeTime >= chargeMax)
            {
                chargeTime = chargeMax;
            }
        }

        if ((Input.GetAxis("Fire1") <= 0.0f) && (swing == null) && (chargeTime > 0.0f))
        {
            swing        = Instantiate(attack, rb.position, rb.rotation); // create an attack hitbox, save as swing
            swingControl = swing.GetComponent <AttackController>();       // get the cotroller script of the attack
            if (swingControl != null)
            {
                swingControl.knockback = (chargeTime / chargeMax) * knockbackMax;
                swingControl.duration  = attackDuration;
            }
            chargeTime = 0.0f; // reset charge time
        }

        if (swing != null)
        {
            swing.transform.position = rb.position;
        }
    }
コード例 #11
0
ファイル: Weapon.cs プロジェクト: heed13/CS-3540-Borderlands
 protected virtual void Start()
 {
     // look up parent by health script, anything with a gun should have hp
     player = gameObject.GetComponentInParent<Health>().gameObject;
     teamId = player.GetComponent<TeamMember> ().teamId;
     atkController = player.GetComponent<AttackController> ();
 }
コード例 #12
0
ファイル: ItemsController.cs プロジェクト: LongJohnny/Burden
        // Use this for initialization
        void Start()
        {
            Light2D torch = GameObject.Find("Torch").GetComponent <Light2D>();

            if (torch == null)
            {
                throw new ArgumentNullException("Torch is not attached to player!");
            }
            _animator = GetComponent <Animator>();
            if (_animator == null)
            {
                throw new ArgumentNullException("Animator is not associated with player!");
            }
            _sanityManager = GetComponent <SanityManager>();
            if (_sanityManager == null)
            {
                throw new ArgumentNullException("Sanity manager is not associated with player!");
            }
            _controller2D = GetComponent <MovementController2D>();
            if (_controller2D == null)
            {
                throw new ArgumentNullException("Controller 2D is not associated with player!");
            }
            _attackController = GetComponent <AttackController>();
            if (_attackController == null)
            {
                throw new ArgumentNullException("Attack controller is not associated with player!");
            }

            _instrumentDisabled = SharedInfo.LostInstrument;
            _torchDisabled      = SharedInfo.LostTorch;

            _torch = torch;
            DeactivateTorch();
        }
コード例 #13
0
 public void OnSceneGUI()
 {
     c             = this.target as AttackController;
     Handles.color = Color.green;
     Handles.DrawWireDisc(c.transform.position, Vector3.forward, c.attackRadius);
     // radius
 }
コード例 #14
0
 void Start()
 {
     myTeamId = GetComponent<TeamMember> ().teamId;
     atkController = GetComponent<AttackController> ();
     weapon = atkController.currentWeapon;
     myRenderer = GetComponentInChildren<MeshRenderer> ();
 }
コード例 #15
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Attack")
     {
         AttackController attack = collision.gameObject.GetComponent <AttackController>();
     }
 }
コード例 #16
0
ファイル: HitEntity.cs プロジェクト: manryan/portfoliocode
    void checkifhit(Collider c)
    {
        if (!entitiesHit.Contains(c.transform.root.gameObject))
        {
            //add them to the list
            entitiesHit.Add(c.transform.root.gameObject);

            //check sibling index to see if we hit head, body or legs

            if (c.transform.GetSiblingIndex() == 0)
            {
                //        Debug.Log("Hit head");
                damage = 3;
            }
            else if (c.transform.GetSiblingIndex() <= 2)
            {
                //      Debug.Log("Hit Body");
                damage = 2;
            }
            else
            {
                //    Debug.Log("hit legs");
                damage = 1;
            }

            ctrl          = c.transform.root.GetComponent <AttackController>();
            ctrl.enemyRef = this;
            ctrl.HandleBlocks((attacktype() + damage + damageCalculator()) * 10f);
            empty = false;
            return;
        }
        empty = true;
    }
コード例 #17
0
 // Use this for initialization
 void Start()
 {
     attackController   = GetComponent <AttackController>();
     equipmentHandler   = GetComponent <EquipmentHandler>();
     movementController = GetComponent <MovementController>();
     uicontroller       = GameObject.FindObjectOfType <UIController>() as UIController;
     health             = maxHealth;
 }
コード例 #18
0
 // Use this for initialization
 void Start()
 {
     rigidbody        = GetComponent <Rigidbody2D>();
     lifeController   = GetComponent <LifeController>();
     attackController = GetComponent <AttackController>();
     animator         = GetComponent <Animator>();
     navMeshAgent     = GetComponentInParent <NavMeshAgent>();
 }
コード例 #19
0
 // Use this for initialization
 void Start()
 {
     attackController = gameObject.transform.Find(weaponPath).GetChild(0).GetComponent <AttackController>(); //inicializar valores
     if (attackController == null)
     {
         Debug.Log("ERRO: Objeto de ataque nao encontrado!");                           //para melhor controle e teste
     }
 }
コード例 #20
0
ファイル: Submarine.cs プロジェクト: payman81/OceanOfCode
 public Submarine(INavigator navigator, IEnemyTracker enemyTracker, IConsole console,
                  AttackController attackController, ChargeController chargeController)
 {
     _navigator        = navigator;
     _enemyTracker     = enemyTracker;
     _console          = console;
     _attackController = attackController;
     _chargeController = chargeController;
 }
コード例 #21
0
ファイル: FireEnemy.cs プロジェクト: MatthewDulworth/GGJ2020
    // -------------------------------------------------
    // FireAttack
    // -------------------------------------------------
    private void FireAttack()
    {
        AttackController fireball = DoAttack("Fireball");

        fireball.transform.parent = null;
        fireball.gameObject.AddComponent <Rigidbody2D>();
        fireball.GetComponent <Rigidbody2D>().velocity = getHitVector(this.launchForce, this.launchAngle, -TargetDirection());
        fireballs.Add(fireball);
    }
コード例 #22
0
ファイル: Enemy.cs プロジェクト: MatthewDulworth/GGJ2020
    public AttackController DoAttack(string name)
    {
        AttackController spawnedAttack = Instantiate(this.attack, this.transform).GetComponent <AttackController>();

        spawnedAttack.isAerial = false;
        spawnedAttack.SetAttack(FindAttack(name));
        attacking = true;
        return(spawnedAttack);
    }
コード例 #23
0
ファイル: Weapon_Hand.cs プロジェクト: BjarkeHou/ProjectGuard
 // Use this for initialization
 void Start()
 {
     Transform parent = transform;
     while (atkCtrl == null) {
         parent = parent.parent;
         atkCtrl = parent.GetComponent<AttackController>();
     }
     game = GameObject.FindWithTag("GameController").GetComponent<GameController>();
 }
コード例 #24
0
ファイル: MeControler.cs プロジェクト: 602147629/GDGJ_Script
        public void addNormalAttack(bool _useAi)
        {
            AiController.SetAi(_useAi);
            var vo = new ActionVo {
                ActionType = Actions.ATTACK
            };

            AttackController.AddAttackList(vo);
        }
コード例 #25
0
    // Use this for initialization
    void Start()
    {
        GameObject p = GameObject.FindGameObjectWithTag("Player");
        mCtrl = p.GetComponent<MovementController>();
        aCtrl = p.GetComponent<AttackController>();
        eCtrl = p.GetComponent<EquipmentController>();

        game = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameController>();
    }
コード例 #26
0
 // Use this for initialization
 void Start()
 {
     moveController = GetComponent<MoveController>();
     animator = GetComponent<Animator>();
     attackController = GetComponent<AttackController>();
     crowdControllable = GetComponent<CrowdControllable>();
     health = GetComponent<Health>();
     player = GetComponent<Player>();
 }
コード例 #27
0
ファイル: Enemy.cs プロジェクト: willieLjohnson/jumper
    void Start()
    {
        controller       = GetComponent <Controller2D>();
        attackController = GetComponent <AttackController>();

        if (target == null)
        {
            target = Player.Instance.transform;
        }
    }
コード例 #28
0
    void Start()
    {
        attackController = GetComponent <AttackController>();

        if (randomEquipment)
        {
            equippedWeapon = weaponList[Random.Range(0, weaponList.Length)];
            equippedShield = shieldList[Random.Range(0, shieldList.Length)];
        }
    }
コード例 #29
0
ファイル: Weapon.cs プロジェクト: BjarkeHou/ProjectGuard
 public void TryToEquip(GameObject wielder)
 {
     if (!equipped)
     {
         transform.Find("PickUpBox").collider.enabled = false;
         equipped = true;
         atkCtrl = wielder.GetComponent<AttackController>();
         wielder.GetComponent<EquipmentController>().Equip(this.gameObject);
     }
 }
コード例 #30
0
 void Awake()
 {
     faceDirection    = Vector2.right;
     renderer         = GetComponent <SpriteRenderer> ();
     rigidbody        = GetComponent <Rigidbody2D> ();
     attackController = GetComponent <AttackController> ();
     originalColor    = renderer.color;
     trail            = GetComponent <TrailRenderer> ();
     anim             = GetComponent <Animator> ();
 }
コード例 #31
0
    void Start()
    {
        _ActivePlayer     = GameObject.Find("Low Poly Warrior");
        _Hud              = GameObject.FindObjectOfType <HUD>();
        _playerController = GameObject.FindObjectOfType <PlayerController>();
        _attackController = _ActivePlayer.GetComponent <AttackController>();

        //    Button _buttonTemplate = gameObject.transform.Find("HUD/RightClickMenu/ButtonListViewport/ButtonListContent/Button").GetComponent<Button>();
        //    //_buttonTemplate = Resources.Load("HUD/RightClickMenu/ButtonListViewport/ButtonListContent/ButtonListContent") as GameObject;
    }
コード例 #32
0
 private void Start()
 {
     movementController  = this.GetComponent <MovementController>();
     animationController = this.GetComponent <AnimationController>();
     attackController    = this.GetComponent <AttackController>();
     CalculatePhysics(jumpHeight, timeToJumpApex);
     if (fallingAnimationThreshold > gravity)
     {
         Debug.Log("Falling animation threshhold is too small");
     }
 }
コード例 #33
0
    void OnCollisionStay(Collision col)
    {
        AttackController attackController = col.gameObject.GetComponent <AttackController>();

        if (attackController != null && attackController.isAttacking)
        {
            damage = (int)(Math.Pow(attackController.attackLevel, 2)) + 10;
            DoDamage?.Invoke(gameObject, damage);
            attackController.isAttacking = false;
        }
    }
コード例 #34
0
    protected virtual void Start()
    {
        controller       = GetComponent <Controller2D>();
        attackController = GetComponent <AttackController>();
        anim             = GetComponent <Animator>();
        sprite           = GetComponent <SpriteRenderer>();

        gravity         = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
    }
コード例 #35
0
    void Start()
    {
        playerStats = GameObject.FindGameObjectWithTag("Player").GetComponent <AttackController>();
        hearts      = new List <Image>();

        for (int i = 0; i < playerStats.maxHealth / 2; i++)
        {
            GameObject spawnedHeart = Instantiate(hearthObj, transform.position, Quaternion.identity, heartsContainer);
            hearts.Add(spawnedHeart.transform.Find("Img").GetComponent <Image>());
        }
    }
コード例 #36
0
    public virtual void CastLocalAttack()
    {
        isAttacking = true;

        AttackController attack = GetAttack();

        attack.Initialize(this);
        attack.SetMovement(directionX, attackSpeed, transform.position);

        StartCoroutine(WaitAttacking());
        AnimateAttack();
    }
コード例 #37
0
	void Awake()
	{
		mc = GetComponent<MoveController> ();
		ac = GetComponent<AttackController> ();
		tm = GetComponent<TeamMember> ();
		hp = GetComponent<Health> ();
		xp = GetComponent<Experience> ();
		an = GetComponent<Animator> ();
		rb = GetComponent<Rigidbody2D> ();
		sr = GetComponent<SpriteRenderer> ();
		bc = GetComponent<BoxCollider2D> ();

	}
コード例 #38
0
     void Awake()
     {
          attackController = GetComponent<AttackController>();
          animator = GetComponent<Animator>();

          isMoving = false;
          movementVector = new Vector2(0, 0);
          direction = new Vector2(0, 0);
          facing = new Vector2(0, -1);
          previousFacing = new Vector2(0, -1);

          canDash = true;
          canMove = true;
          isDashing = false;
          dashIn = 0;
     }
コード例 #39
0
     void OnTriggerEnter2D(Collider2D other)
     {
          if (other.gameObject.tag == "Player")
          {
               grabbed = true;
               attackController = other.gameObject.GetComponent<AttackController>();
               attackController.Ammo += ammoValue;

               Tweener tween = transform.DOMove(Camera.main.ScreenToWorldPoint(new Vector3(Camera.main.pixelWidth - 100, Camera.main.pixelHeight - 10)), 1, false)
                               .OnStepComplete(() =>
                               {
                                    Destroy(gameObject);
                               });
               //tween.OnUpdate(() => {
               //    tween.ChangeEndValue(new Vector3(Camera.main.pixelWidth - 100, Camera.main.pixelHeight - 10));
               //    Debug.Log("test");
               //});
          }
     }
コード例 #40
0
     void Awake()
     {
          attackController = GetComponent<AttackController>();
          animator = GetComponent<Animator>();

          isMoving = false;
          movementVector = new Vector2(0, 0);
          facing = new Vector2(0, -1);
          previousFacing = new Vector2(0, -1);

          canDash = true;
          canMove = true;
          isDashing = false;
          dashIn = 0;
          IsInMenu = false;

          knockbackForce = 8;
          isKnockedBack = false;
          timeSpentKnockedBack = 0;
          knockBackTime = 0.12f;
          GameManager.Notifications.AddListener(this, "PlayerExitMenu");
          GameManager.Notifications.AddListener(this, "PlayerInMenu");
     }
コード例 #41
0
    /*
    void Awake()
    {
        if (player == null)
        {
            player = gameObject;
        }else if(player != gameObject)
        {
            Destroy(gameObject);
        }
    }*/
    void Start()
    {
        state = new StandingState();
        attackState = new IdleAttackState();
        animator = GetComponent<Animator>();
        skillManager = gameObject.AddComponent<SkillManager>();
        AttackCollider.SetActive(false);
        health = GetComponent<Health>();
        controller = GetComponent<MoveController>();
        crowdControllable = GetComponent<CrowdControllable>();
        mana = GetComponent<Mana>();
        attack = GetComponentInChildren<DealDamage>();
        defense = GetComponent<Defense>();
        attackController = GetComponent<AttackController>();
        gravity = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        audiosource = GetComponent<AudioSource>();

        initialRegenTime = 6;
        regenTick = 2;

        DontDestroyOnLoad(gameObject);

        skill[0] = null;
        skill[1] = null;
        skill[2] = null;
        skill[3] = null;
        threatLevel = damageDealt = 0;

        GetComponent<ID>().setTime(false);
        CCI = GameObject.Find("Main Process").GetComponentInChildren<Character_Class_Info>();
        si = GameObject.Find("Main Process").GetComponentInChildren<Skill_info>();
        Fully_Update();
    }
コード例 #42
0
 void Start()
 {
     myTeamId = GetComponent<TeamMember> ().teamId;
     atkController = GetComponent<AttackController> ();
     weapon = atkController.weapon;
 }
コード例 #43
0
 public override void AddItemToInventory(Collider2D player, int value)
 {
      attackController = player.gameObject.GetComponent<AttackController>();
      attackController.Bombs += value;
 }
コード例 #44
0
 // Use this for initialization
 void Start()
 {
     this.controller  = GetComponent<CharacterController>();
     this.attackController = GetComponent<AttackController>();
     this.destPosition = transform.position;
 }
コード例 #45
0
ファイル: UnitMovement.cs プロジェクト: jgirald/ES2015F
 // Use this for initialization
 void Awake()
 {
     seeker = GetComponent<Seeker>();
     characterController = GetComponent<CharacterController>();
     attack = GetComponent<AttackController> ();
     animator = GetComponent<Animator>();
     hasTarget = false;
     status = Status.idle;
     callback = null;
 }
コード例 #46
0
 // Use this for initialization
 void Start()
 {
     //playerMove = this.GetComponent<MovementController>();
     playerAttack = this.GetComponent<AttackController>();
 }
コード例 #47
0
 // Use this for initialization
 void Start()
 {
     player = FindObjectOfType<Player>();
      playerHealth = player.GetComponent<Health>();
      playerAttackController = player.GetComponent<AttackController>();
 }
コード例 #48
0
ファイル: Skills.cs プロジェクト: MChen7209/Yi-Ju-Chen
 void Awake()
 {
     god = GameObject.FindGameObjectWithTag("God").GetComponent<UnifiedSuperClass>();
     skillsController = god.SkillsController;
     atkController = transform.root.GetComponentInChildren<AttackController>();
     //		Debug.Log(atkController.SecondSkillLock);
 }
コード例 #49
0
    /// <summary>
    /// Creates the attack listing.
    /// </summary>
    /// <returns>The attack listing.</returns>
    /// <param name="atd">Atd.</param>
    protected AttackController.AttackData CreateAttackListing(AttackController.AttackData atd)
    {
        EditorGUILayout.BeginHorizontal ();
        atd.atk.showInEditor = EditorGUILayout.Foldout (atd.atk.showInEditor, atd.atk.attackName);
        if (GUILayout.Button ("-", GUILayout.Width (20), GUILayout.Height (14))) {
            ScriptableObject.DestroyImmediate (atd.atk);
            atd = null;
        }
        EditorGUILayout.EndHorizontal ();

        if (atd != null && atd.atk.showInEditor) {

            GUIStyle attacksStyle = new GUIStyle (GUI.skin.box);
            attacksStyle.padding = new RectOffset (12, 1, 5, 5);

            EditorGUILayout.BeginVertical (attacksStyle);

            // get all of the attack scripts
            int thisScriptIndex = 0;

            // get all of the attack scripts
            GUIContent attackScriptLabel = new GUIContent ("Attack Script",
                                                           "Attack Script\n" +
                                                           "The script the attack will be executing when the attack is used.");
            GUIContent[] attackScriptOptions = new GUIContent[AttackTypeList.Count];
            int index = 0;
            foreach (string key in AttackTypeList) {
                attackScriptOptions[index] = new GUIContent(key);
                if (atd.atk.GetType () == GetAttackType (key)) {
                    thisScriptIndex = index;
                }
                index++;
            }

            // list the attack scripts
            int tempAttackScriptIndex = EditorGUILayout.Popup (attackScriptLabel, thisScriptIndex, attackScriptOptions);
            if (tempAttackScriptIndex != thisScriptIndex) {
                Attack tempAtk = Instantiate (atd.atk);
                Attack newAtk = GetAttack (attackScriptOptions[tempAttackScriptIndex].text);
                atd.atk = Instantiate (newAtk);
                atd.atk.CopyComponents (tempAtk);
                ScriptableObject.DestroyImmediate (tempAtk);
                ScriptableObject.DestroyImmediate (newAtk);
            }

            // add the attack's components
            atd.atk.EditorGUISetup ();

            // add the attack inputs
            GUIStyle attacksInputStyle = new GUIStyle (GUI.skin.box);
            attacksInputStyle.padding = new RectOffset (12, 1, 1, 5);

            EditorGUILayout.Space ();
            EditorGUILayout.BeginHorizontal ();
            EditorGUILayout.LabelField ("Activation Parameters");
            EditorGUILayout.EndHorizontal ();

            EditorGUILayout.BeginVertical (attacksInputStyle);
            EditorGUILayout.BeginHorizontal ();
            GUIContent triggerLabel = new GUIContent ("Trigger",
                                                      "Trigger\n" +
                                                      "The option for a trigger that needs to happen in order for this attack to start.");
            AttackController.AttackTrigger tempTrigger = (AttackController.AttackTrigger) EditorGUILayout.EnumPopup (triggerLabel, atd.atkTrig);
            if (atd.atkTrig != tempTrigger) {
                atd.atkTrig = tempTrigger;
            }
            EditorGUILayout.EndHorizontal ();

            EditorGUILayout.BeginHorizontal ();
            GUIContent comboLabel = new GUIContent ("Combo Label",
                                                    "Combo Label\n" +
                                                    "If this attack is triggered after another attack, add it's ID here. Otherwise leave this section blank.");
            string tempComboID = EditorGUILayout.TextField (comboLabel, atd.comboStarterID);
            if (atd.comboStarterID != tempComboID) {
                atd.comboStarterID = tempComboID;
            }
            EditorGUILayout.EndHorizontal ();

            EditorGUILayout.BeginHorizontal ();

            // if there are no attack inputs
            if (atd.input.Count == 0) {
                AttackController.AttackInput ai = new AttackController.AttackInput ();
                ai.Pos = AttackController.AttackPositionState.Neutral;
                atd.input.Add (ai);
            }

            GUIContent posDirLabel = new GUIContent ("Position State and Input Directions",
                                                     "Position State\n" +
                                                     "The state the character's movement controller has to be in for this attack to activate.\n\n" +
                                                     "Input Direction\n" +
                                                     "The directional influence the attacker is using while in the selected position state.\n" +
                                                     "For a player this would be the joystick position when pressing the attack button.");
            EditorGUILayout.LabelField (posDirLabel);
            if (atd.input.Count < Enum.GetValues(typeof(AttackController.AttackPositionState)).Length) {
                if (GUILayout.Button ("+", GUILayout.Width (20), GUILayout.Height (14))) {
                    AttackController.AttackInput ai = new AttackController.AttackInput ();
                    if (atd.InputContains (AttackController.AttackPositionState.Neutral) == -1) {
                        ai.Pos = AttackController.AttackPositionState.Neutral;
                    } else if (atd.InputContains (AttackController.AttackPositionState.Dash) == -1) {
                        ai.Pos = AttackController.AttackPositionState.Dash;
                    } else if (atd.InputContains (AttackController.AttackPositionState.Air) == -1) {
                        ai.Pos = AttackController.AttackPositionState.Air;
                    }
                    atd.input.Add (ai);
                }
            }
            EditorGUILayout.EndHorizontal ();

            // add the attack inputs
            for (int posIndex = 0; posIndex < atd.input.Count; posIndex++) {

                EditorGUILayout.BeginHorizontal ();
                GUIContent posStateLabel = new GUIContent ("Input",
                                                           "Input\n" +
                                                           "An input necessary to perform this attack.");
                atd.input[posIndex].showData = EditorGUILayout.Foldout (atd.input[posIndex].showData, posStateLabel);
                AttackController.AttackPositionState tempAttackPosition = (AttackController.AttackPositionState) EditorGUILayout.EnumPopup (atd.input[posIndex].Pos);
                if (atd.input[posIndex].Pos != tempAttackPosition && atd.InputContains (tempAttackPosition) == -1) {
                    atd.input[posIndex].Pos = tempAttackPosition;
                }
                if (GUILayout.Button ("-", GUILayout.Width (20), GUILayout.Height (14))) {
                    atd.input.RemoveAt (posIndex);
                    break;
                }
                EditorGUILayout.EndHorizontal ();

                if (atd.input[posIndex].showData) {
                    for (int dirIndex = 0; dirIndex < Enum.GetValues(typeof(AttackController.AttackDirection)).Length; dirIndex++) {
                        EditorGUILayout.BeginHorizontal ();
                        if (atd.input[posIndex].Dir.Contains ((AttackController.AttackDirection)dirIndex)) {
                            bool tempDir = EditorGUILayout.ToggleLeft (((AttackController.AttackDirection)dirIndex).ToString (), true);
                            if (!tempDir) {
                                int dir = atd.input[posIndex].Dir.IndexOf ((AttackController.AttackDirection)dirIndex);
                                atd.input[posIndex].Dir.RemoveAt (dir);
                                break;
                            }
                        } else {
                            bool tempDir = EditorGUILayout.ToggleLeft (((AttackController.AttackDirection)dirIndex).ToString (), false);
                            if (tempDir) {
                                atd.input[posIndex].Dir.Add ((AttackController.AttackDirection)dirIndex);
                                break;
                            }
                        }
                        EditorGUILayout.EndHorizontal ();
                    }
                }

            }

            EditorGUILayout.EndVertical ();

            EditorGUILayout.EndVertical ();
        }

        return atd;
    }
コード例 #50
0
 // Use this for initialization
 void Start()
 {
     this.controller  = GetComponent<CharacterController>();
     this.attackController = GetComponent<AttackController>();
     this.target = transform.position;
     this.isDead = false;
 }