コード例 #1
0
    /// <summary>
    /// Selects all objects tagged as "Enemy" from the _attackpoint to the _range
    /// </summary>
    /// <param name="_attackPoint">checks the range of enemies from this point</param>
    /// <param name="_range">distance from the enemy position to the attack point</param>
    private void Attack(Vector3 _attackPoint, float _range)
    {
        // this is a counter that determines what attack is executed
        _currentAttack++;

        // selects all the enemies
        List <GameObject> _damageGroup = GameObject.FindGameObjectsWithTag("Enemy").ToList();

        // holder variables
        Rigidbody            _pickedBody;
        AttributesController _attributesController = GetComponent <AttributesController>();

        // pick all the enemies
        foreach (GameObject _object in _damageGroup)
        {
            // if an enemy is within range
            if (Vector3.Distance(_object.transform.position, _attackPoint) <= _range)
            {
                // damage unit
                _attributesController.Damage(_object, _attributesController.damage);

                //  gets the rigidbody of the object
                _pickedBody = _object.GetComponent <Rigidbody>();

                //  knockback the object
                Knockback(_pickedBody, knockbackDistance);
            }
        }

        //  if the attack state exceeds the maximum attack count reset
        if (_currentAttack >= maxAttackCount)
        {
            _currentAttack = (int)_attackState.initialAttack;
        }
    }
コード例 #2
0
 void Start()
 {
     attributes         = GetComponent <AttributesController>();
     sectorSensors      = GetComponents <SectorSensor>();
     distanceSensors    = GetComponents <DistanceSensor>();
     movementController = GetComponent <MovementController>();
     rb = GetComponent <Rigidbody>();
 }
コード例 #3
0
    public void Damage(GameObject _unit, int _damage)
    {
        AttributesController _attributeController = _unit.GetComponent <AttributesController>();

        if (_attributeController != null)
        {
            _attributeController.currentHealth = _attributeController.currentHealth - _damage;
        }
    }
コード例 #4
0
 public IHttpActionResult GetAttributes()
 {
     CodebookResponse _responseEnvelope = new CodebookResponse(Request.Properties["requestId"].ToString(), true);
     String apiUser = RequestContext.Principal.Identity.Name;
     AutomationManager.AttributeObjectToAttributeApiObject(AutomationManager.attributes);
     AttributesManager = new AttributesManager(AutomationManager.IAttributeRepository.Object);
     var result = new AttributesController(AttributesManager, this.Request, this.RequestContext).GetAttributes() as OkNegotiatedContentResult<CodebookResponse>;
     return Ok(result.Content);
 }
コード例 #5
0
    public virtual void Revive()
    {
        if (AttributesController.health <= 0)
        {
            AnimationController.SetAnimationParameter(EnemyAnimatorParameter.Revive);
            contactCollider.enabled = true;
        }

        AttributesController.ResetAllAttributes();
    }
コード例 #6
0
    public virtual void Revive()
    {
        if (AttributesController.health <= 0)
        {
            AnimationController.SetAnimationParameter(PlayerAnimatorParameter.Revive); //AnimationController.SetRevive();
            contactCollider.enabled = true;
        }

        AttributesController.ResetAllAttributes();
        GameManager.instance.screenUIController.playerUIController.OnEnable();
    }
コード例 #7
0
    // Use this for initialization
    void Start()
    {
        Utility.DebugLog = true;
        experiment       = new SimpleExperiment();
        XmlDocument xmlConfig = new XmlDocument();
        TextAsset   textAsset = (TextAsset)Resources.Load("experiment.config");

        xmlConfig.LoadXml(textAsset.text);
        experiment.SetOptimizer(this);

        // Calculate number of inputs
        numInputs = 0;
        AttributesController unitAttrs = Unit.GetComponent <AttributesController>();

        SectorSensor[]     sectorSensors   = Unit.GetComponents <SectorSensor>();
        DistanceSensor[]   distanceSensors = Unit.GetComponents <DistanceSensor>();
        MovementController movement        = Unit.GetComponent <MovementController>();

        if (unitAttrs != null)
        {
            numInputs += unitAttrs.needsFood ? 1 : 0;
            numInputs += unitAttrs.needsWater ? 1 : 0;
        }
        if (movement != null)
        {
            numInputs += movement.senseSpeed ? 1 : 0;
            numInputs += movement.senseSwimming ? 1 : 0;
        }
        if (sectorSensors.Length > 0)
        {
            foreach (SectorSensor sectorSensor in sectorSensors)
            {
                //numInputs += sectorSensor.senseAngles ? sectorSensor.numSectors * 2 : sectorSensor.numSectors;
                numInputs += sectorSensor.NumSenses;
            }
        }
        if (distanceSensors.Length > 0)
        {
            foreach (DistanceSensor distanceSensor in distanceSensors)
            {
                numInputs += distanceSensor.numSensors;
            }
        }

        experiment.Initialize("Car Experiment", xmlConfig.DocumentElement, numInputs, NumOutputs);

        champFileSavePath = Application.persistentDataPath + string.Format("/{0}.champ.xml", SaveFileName);
        popFileSavePath   = Application.persistentDataPath + string.Format("/{0}.pop.xml", SaveFileName);

        print(champFileSavePath);
    }
コード例 #8
0
 protected virtual void OnEnable()
 {
     //Check Until GameManager instance is not Null
     StartCoroutine(WaitUntilConditionHappenCoroutine(ConditionFunc: () =>
     {
         bool condition = GameManager.instance?.gamePlayMode == GamePlayMode.AR;
         return(condition);
     },
                                                      action: () =>
     {
         transform.localScale = Vector3.one * GameManager.instance.characterLocalScaleForAR;
         AttributesController.ResetAllAttributes();
     }));
 }
コード例 #9
0
    void Start()
    {
        //Script reference
        ac = controller.GetComponent <AttributesController>();

        #region Starting Values For Variables And Attributes
        //Starting Values for timers
        fatigueTimer    = startFatigue;
        exhaustionTimer = maxExhaustion;

        //Start with the correct values of the attributes
        for (int i = 0; i < ac.attributes.Count; i++)
        {
            if (ac.attributes[i].name == "hunger")
            {
                hungerDrain = ac.attributes[i].charge;
                maxHunger   = ac.attributes[i].value;
                vHunger     = maxHunger;
            }

            if (ac.attributes[i].name == "thirst")
            {
                thirstDrain = ac.attributes[i].charge;
                maxThirst   = ac.attributes[i].value;
                vThirst     = maxThirst;
            }

            if (ac.attributes[i].name == "stamina")
            {
                staminaCharge = ac.attributes[i].charge;
                maxStamina    = ac.attributes[i].value;
                vStamina      = maxStamina;
            }
        }
        #endregion
    }
コード例 #10
0
 void Start()
 {
     controller = GameObject.FindGameObjectWithTag("Player").GetComponent <AttributesController>();
 }
コード例 #11
0
        public void SetUp()
        {
            _mediator = Substitute.For <IMediator>();

            _sut = new AttributesController(_mediator);
        }
コード例 #12
0
 void Start()
 {
     controller = GameObject.FindGameObjectWithTag("Player").GetComponent<AttributesController>();
 }